Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(defn deregister [write-db]
(let [the-right-driver (java.sql.DriverManager/getDriver (format "jdbc:%s:%s" (:subprotocol write-db) (:subname write-db)))]
(doseq [driver (enumeration-seq (java.sql.DriverManager/getDrivers))
:when (not= (class driver) (class the-right-driver))]
(java.sql.DriverManager/deregisterDriver driver))))
(defn postgres? []
(every? #(instance? org.postgresql.Driver %)
(enumeration-seq (java.sql.DriverManager/getDrivers))))
(defn hypersql? []
(every? #(instance? org.hsqldb.jdbc.JDBCDriver %)
(enumeration-seq (java.sql.DriverManager/getDrivers))))
> (deregister {:classname "org.hsqldb.jdbcDriver"
:subprotocol "hsqldb"
:subname (str "mem:" (java.util.UUID/randomUUID) ";shutdown=true;hsqldb.tx=mvcc;sql.syntax_pgs=true")})
;=> nil
> (postgres?)
;=> false
> (hypersql?)
;=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.