This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-15
Channels
- # arachne (6)
- # aws-lambda (3)
- # beginners (14)
- # boot (56)
- # cider (8)
- # cljs-dev (5)
- # cljsrn (11)
- # clojure (240)
- # clojure-dusseldorf (3)
- # clojure-greece (165)
- # clojure-italy (5)
- # clojure-romania (1)
- # clojure-russia (24)
- # clojure-uk (30)
- # clojure-ukraine (3)
- # clojurescript (29)
- # core-async (6)
- # css (1)
- # cursive (25)
- # datascript (6)
- # datomic (61)
- # dirac (1)
- # events (3)
- # hoplon (1)
- # instaparse (3)
- # jobs (4)
- # juxt (28)
- # lein-figwheel (7)
- # leiningen (19)
- # luminus (1)
- # lumo (2)
- # nyc (1)
- # off-topic (19)
- # om (25)
- # onyx (4)
- # parinfer (2)
- # pedestal (23)
- # perun (20)
- # re-frame (44)
- # reagent (20)
- # remote-jobs (3)
- # ring (3)
- # ring-swagger (5)
- # rum (12)
- # slack-help (3)
- # spacemacs (25)
- # specter (62)
- # sql (16)
- # unrepl (313)
- # yada (4)
I use Luminus with Postgres. By default Luminus extends some protocols from clojure.java.jdbc, as well as adds set-parameter to some Clojure/Java types. How to extend the same protocols/types with pgjdbc-ng?
I understand that clojure.java.jdbc is just a wrapped for the stock jdbc, and won't work with pgjdbc-ng.
The easiest thing may be to continue using the default interface and use pgjdbc-ng only where I actually need it (for LISTEN
).
It’s not immediately obvious why pgjdbc-ng
couldn’t work with clojure.java.jdbc
, at least for the common jdbc features?
It permits connections to be opened against javax.sql.DataSource
impls
I was thinking that maybe clojure.java.jdbc hardcodes the dependency on Java's jdbc.
java.jdbc
has actually been tested with pgjdbc-ng
I may need to make a new release with that update in… let me just check...
…no, that’s in 0.7.0-alpha2: http://dev.clojure.org/jira/browse/JDBC-150
@not-raspberry java.jdbc
uses whatever JDBC driver you add as a dependency and whatever driver class you specify. Some have shortcuts (e.g., mysql
, mssql
, postgres
— default PostgreSQL drive). That change added pgsql
as a shortcut for the Impossibl pgjdbc-ng driver.
These are the drivers java.jdbc
knows about out of the box:
(def ^{:private true :doc "Map of classnames to subprotocols"} classnames
{"derby" "org.apache.derby.jdbc.EmbeddedDriver"
"h2" "org.h2.Driver"
"hsqldb" "org.hsqldb.jdbcDriver"
"jtds:sqlserver" "net.sourceforge.jtds.jdbc.Driver"
"mysql" "com.mysql.jdbc.Driver"
"oracle:oci" "oracle.jdbc.OracleDriver"
"oracle:thin" "oracle.jdbc.OracleDriver"
"postgresql" "org.postgresql.Driver"
"pgsql" "com.impossibl.postgres.jdbc.PGDriver"
"sqlite" "org.sqlite.JDBC"
"sqlserver" "com.microsoft.sqlserver.jdbc.SQLServerDriver"})
and it has the following shortcut aliases too (def ^{:private true :doc "Map of schemes to subprotocols"} subprotocols
{"hsql" "hsqldb"
"jtds" "jtds:sqlserver"
"mssql" "sqlserver"
"oracle" "oracle:thin"
"postgres" "postgresql"})
Anything else you need to specify long-hand like this DriverManager (alternative / legacy style):
:subprotocol (required) a String, the jdbc subprotocol
:subname (required) a String, the jdbc subname
:classname (optional) a String, the jdbc driver class name
(others) (optional) passed to the driver as properties.
The “built-in” names can be used with this shorthand:
DriverManager (preferred):
:dbtype (required) a String, the type of the database (the jdbc subprotocol)
:dbname (required) a String, the name of the database
:host (optional) a String, the host name/IP of the database
(defaults to 127.0.0.1)
:port (optional) a Long, the port of the database
(defaults to 3306 for mysql, 1433 for mssql/jtds, else nil)
(others) (optional) passed to the driver as properties.
LMK if anything about that isn’t clear.
Thanks, everyone, I'll try tomorrow.
Feel free to ping me if you have any issues with java.jdbc
!