java.jdbc

Create connections for outdated Oracle SID

Details

  • Type: Feature Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

There are 2 cases for oracle db connection URI:
jdbc:oracle:thin:@<hostName>:<portNumber>:<sid>; (if you have sid)
jdbc:oracle:thin:@<hostName>:<portNumber>/serviceName; (if you have oracle service name)

The current clojure.jdbc implementation creates the second format, with "/" char.
E.g.
(def my-oracle-db {:dbtype "oracle" :dbname "dbname"...

creates URI
jdbc:oracle:thin:@host:port/dbname

But this can't work with outdated SID connections.

Could I ask to add the check for a "sid" string, so if I write
(def my-oracle-db {:dbtype "oracle" :dbname "sid:dbname"...

I'll receive the following URI:
jdbc:oracle:thin:@host:port:dbname

it's a java.jdbc\src\main\clojure\clojure\java\jdbc.clj:384

The probable solution could looks like this:

db-sep (if (= "sqlserver" subprotocol) ";DATABASENAME=" "/")
url (cond (= "h2:mem" dbtype)
(str "jdbc:" subprotocol ":" dbname ";DB_CLOSE_DELAY=-1")
(#{"derby" "h2" "hsqldb" "sqlite"} subprotocol)
(str "jdbc:" subprotocol ":" dbname)
+ (= "oracle" dbtype)
+ (str "jdbc:" subprotocol ":"
+ (host-prefixes subprotocol "//")
+ host
+ (when port (str ":" port))
+ (if (= (.indexOf (str dbname) "sid:") 0)
+ (str ":" (str/replace dbname #"sid:" ""))
+ (str "/" dbname)))
:else
(str "jdbc:" subprotocol ":"
(host-prefixes subprotocol "//")
host
(when port (str ":" port))
db-sep dbname))
db-sep (if (= "sqlserver" subprotocol) ";DATABASENAME=" "/")

Activity

Hide
Sean Corfield added a comment -

Added oracle:sid as a new dbtype that uses the old-style dbname separator.

Show
Sean Corfield added a comment - Added oracle:sid as a new dbtype that uses the old-style dbname separator.
Hide
Sean Corfield added a comment -

Release 0.7.9 is heading to Maven Central!

Show
Sean Corfield added a comment - Release 0.7.9 is heading to Maven Central!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: