Skip to content

Commit ed5df34

Browse files
yahondaclaude
andcommitted
Add ojdbc17, ojdbc11 and ojdbc8 to JDBC driver search list
The driver search only looked for ojdbc7.jar and ojdbc6.jar on Java 7+. Modern Oracle JDBC drivers use ojdbc17.jar (Java 17+), ojdbc11.jar (Java 11+) and ojdbc8.jar (Java 8+). Build the search list based on the running Java major version so that only compatible jars are tried, in priority order preferring the newest driver. Older drivers are still searched as fallbacks since they run on newer Java versions. Ref: https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5587fab commit ed5df34

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ In addition install either ruby-oci8 (for MRI/YARV) or copy Oracle JDBC driver t
154154
If you are using MRI Ruby implementation then you need to install ruby-oci8 gem (version 2.1 or higher)
155155
as well as Oracle client, e.g. [Oracle Instant Client](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html).
156156

157-
If you are using JRuby then you need to download latest [Oracle JDBC driver](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html) - either ojdbc7.jar for Java 8 and 7, ojdbc6.jar for Java 6, 7, 8 or ojdbc5.jar for Java 5. You can refer [the support matrix](http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#01_03) for details.
157+
If you are using JRuby then you need to download latest [Oracle JDBC driver](https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html) - ojdbc17.jar for Java 17+, ojdbc11.jar for Java 11+, or ojdbc8.jar for Java 8+.
158158

159159
And copy this file to one of these locations. JDBC driver will be searched in this order:
160160

lib/plsql/jdbc_connection.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
require "java"
33
require "jruby"
44

5-
# ojdbc6.jar or ojdbc5.jar file should be in JRUBY_HOME/lib or should be in ENV['PATH'] or load path
5+
# Oracle JDBC driver jar should be in JRUBY_HOME/lib or should be in ENV['PATH'] or load path
66

77
java_version = java.lang.System.getProperty("java.version")
8-
ojdbc_jars = if java_version =~ /^1.5/
9-
%w(ojdbc5.jar)
10-
elsif java_version =~ /^1.6/
11-
%w(ojdbc6.jar)
12-
elsif java_version >= "1.7"
13-
# Oracle 11g client ojdbc6.jar is also compatible with Java 1.7
14-
# Oracle 12c client provides new ojdbc7.jar
15-
%w(ojdbc7.jar ojdbc6.jar)
8+
java_major = if java_version =~ /^1\.(\d+)/
9+
$1.to_i
1610
else
17-
[]
11+
java_version.to_i
1812
end
1913

14+
ojdbc_jars = []
15+
ojdbc_jars << "ojdbc17.jar" if java_major >= 17
16+
ojdbc_jars << "ojdbc11.jar" if java_major >= 11
17+
ojdbc_jars << "ojdbc8.jar" if java_major >= 8
18+
ojdbc_jars << "ojdbc7.jar" if java_major >= 7
19+
ojdbc_jars << "ojdbc6.jar" if java_major >= 6
20+
ojdbc_jars << "ojdbc5.jar" if java_major == 5
21+
2022
if ENV_JAVA["java.class.path"] !~ Regexp.new(ojdbc_jars.join("|"))
2123
# On Unix environment variable should be PATH, on Windows it is sometimes Path
2224
env_path = (ENV["PATH"] || ENV["Path"] || "").split(File::PATH_SEPARATOR)

0 commit comments

Comments
 (0)