Standard implementations of get-datasource
and get-connection
.
Standard implementations of `get-datasource` and `get-connection`.
A map of all known database types (including aliases) to the class name(s)
and port that next.jdbc
supports out of the box. For databases that have
non-standard prefixes for the :dbname
and/or :host
values in the JDBC
string, this table includes :dbname-separator
and/or :host-prefix
. The
default prefix for :dbname
is either /
or :
and for :host
it is //
.
For local databases, with no :host
/:port
segment in their JDBC URL, a
value of :none
is provided for :host
in this table.
For known database types, you can use :dbtype
(and omit :classname
).
If you want to use a database that is not in this list, you can specify
a new :dbtype
along with the class name of the JDBC driver in :classname
.
You will also need to specify :port
. For example:
{:dbtype "acme" :classname "com.acme.JdbcDriver" ...}
The value of :dbtype
should be the string that the driver is associated
with in the JDBC URL, i.e., the value that comes between the jdbc:
prefix and the ://<host>...
part. In the above example, the JDBC URL
that would be generated would be jdbc:acme://<host>:<port>/<dbname>
.
If you want next.jdbc
to omit the host/port part of the URL, specify
:host :none
, which would produce a URL like: jdbc:acme:<dbname>
,
which allows you to work with local databases (or drivers that do not
need host/port information).
The default prefix for the host name (or IP address) is //
. You
can override this via the :host-prefix
option.
The default separator between the host/port and the database name is /
.
The default separator between the subprotocol and the database name,
for local databases with no host/port, is :
. You can override this
via the :dbname-separator
option.
JDBC drivers are not provided by next.jdbc
-- you need to specify the
driver(s) you need as additional dependencies in your project. For
example:
[com.acme/jdbc "1.2.3"] ; lein/boot
or:
{com.acme/jdbc {:mvn/version "1.2.3"}} ; CLI/deps.edn
Note: the :classname
value can be a string or a vector of strings. If
a vector of strings is provided, an attempt will be made to load each
named class in order, until one succeeds. This allows for a given :dbtype
to be used with different versions of a JDBC driver, if the class name
has changed over time (such as with MySQL).
A map of all known database types (including aliases) to the class name(s) and port that `next.jdbc` supports out of the box. For databases that have non-standard prefixes for the `:dbname` and/or `:host` values in the JDBC string, this table includes `:dbname-separator` and/or `:host-prefix`. The default prefix for `:dbname` is either `/` or `:` and for `:host` it is `//`. For local databases, with no `:host`/`:port` segment in their JDBC URL, a value of `:none` is provided for `:host` in this table. For known database types, you can use `:dbtype` (and omit `:classname`). If you want to use a database that is not in this list, you can specify a new `:dbtype` along with the class name of the JDBC driver in `:classname`. You will also need to specify `:port`. For example: `{:dbtype "acme" :classname "com.acme.JdbcDriver" ...}` The value of `:dbtype` should be the string that the driver is associated with in the JDBC URL, i.e., the value that comes between the `jdbc:` prefix and the `://<host>...` part. In the above example, the JDBC URL that would be generated would be `jdbc:acme://<host>:<port>/<dbname>`. If you want `next.jdbc` to omit the host/port part of the URL, specify `:host :none`, which would produce a URL like: `jdbc:acme:<dbname>`, which allows you to work with local databases (or drivers that do not need host/port information). The default prefix for the host name (or IP address) is `//`. You can override this via the `:host-prefix` option. The default separator between the host/port and the database name is `/`. The default separator between the subprotocol and the database name, for local databases with no host/port, is `:`. You can override this via the `:dbname-separator` option. JDBC drivers are not provided by `next.jdbc` -- you need to specify the driver(s) you need as additional dependencies in your project. For example: `[com.acme/jdbc "1.2.3"] ; lein/boot` or: `{com.acme/jdbc {:mvn/version "1.2.3"}} ; CLI/deps.edn` Note: the `:classname` value can be a string or a vector of strings. If a vector of strings is provided, an attempt will be made to load each named class in order, until one succeeds. This allows for a given `:dbtype` to be used with different versions of a JDBC driver, if the class name has changed over time (such as with MySQL).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close