Liking cljdoc? Tell your friends :D

next.jdbc

The public API of the next generation java.jdbc library.

The basic building blocks are the java.sql/javax.sql classes:

  • DataSource -- something to get connections from,
  • Connection -- an active connection to the database,
  • PreparedStatement -- SQL and parameters combined, from a connection,

and the following functions and a macro:

  • reducible! -- given a connectable and SQL + parameters or a statement, return a reducible that, when reduced will execute the SQL and consume the ResultSet produced,
  • execute! -- given a connectable and SQL + parameters or a statement, execute the SQL, consume the ResultSet produced, and return a vector of hash maps representing the rows (@1); this can be datafied to allow navigation of foreign keys into other tables (either by convention or via a schema definition),
  • execute-one! -- given a connectable and SQL + parameters or a statement, execute the SQL, consume the first row of the ResultSet produced, and return a hash map representing that row; this can be datafied to allow navigation of foreign keys into other tables (either by convention or via a schema definition),
  • prepare -- given a Connection and SQL + parameters, construct a new PreparedStatement; in general this should be used with with-open,
  • transact -- the functional implementation of with-transaction,
  • with-transaction -- execute a series of SQL operations within a transaction.

@1 result sets are built, by default, as vectors of hash maps, containing qualified keywords as column names, but the row builder and result set builder machinery is open and alternatives are provided to produce unqualified keywords as column names, and to produce a vector the column names followed by vectors of column values for each row, and lower-case variants of each.

The following options are supported wherever a PreparedStatement is created:

  • :concurrency -- :read-only, :updatable,
  • :cursors -- :close, :hold
  • :fetch-size -- the fetch size value,
  • :max-rows -- the maximum number of rows to return,
  • :result-type -- :forward-only, :scroll-insensitive, :scroll-sensitive,
  • :return-keys -- either true or a vector of key names to return,
  • :timeout -- the query timeout.
The public API of the next generation java.jdbc library.

The basic building blocks are the `java.sql`/`javax.sql` classes:
* `DataSource` -- something to get connections from,
* `Connection` -- an active connection to the database,
* `PreparedStatement` -- SQL and parameters combined, from a connection,

and the following functions and a macro:
* `reducible!` -- given a connectable and SQL + parameters or a statement,
    return a reducible that, when reduced will execute the SQL and consume
    the `ResultSet` produced,
* `execute!` -- given a connectable and SQL + parameters or a statement,
    execute the SQL, consume the `ResultSet` produced, and return a vector
    of hash maps representing the rows (@1); this can be datafied to allow
    navigation of foreign keys into other tables (either by convention or
    via a schema definition),
* `execute-one!` -- given a connectable and SQL + parameters or a statement,
    execute the SQL, consume the first row of the `ResultSet` produced, and
    return a hash map representing that row; this can be datafied to allow
    navigation of foreign keys into other tables (either by convention or
    via a schema definition),
* `prepare` -- given a `Connection` and SQL + parameters, construct a new
    `PreparedStatement`; in general this should be used with `with-open`,
* `transact` -- the functional implementation of `with-transaction`,
* `with-transaction` -- execute a series of SQL operations within a transaction.

@1 result sets are built, by default, as vectors of hash maps, containing
    qualified keywords as column names, but the row builder and result set
    builder machinery is open and alternatives are provided to produce
    unqualified keywords as column names, and to produce a vector the
    column names followed by vectors of column values for each row, and
    lower-case variants of each.

The following options are supported wherever a `PreparedStatement` is created:
* `:concurrency` -- `:read-only`, `:updatable`,
* `:cursors` -- `:close`, `:hold`
* `:fetch-size` -- the fetch size value,
* `:max-rows` -- the maximum number of rows to return,
* `:result-type` -- `:forward-only`, `:scroll-insensitive`, `:scroll-sensitive`,
* `:return-keys` -- either `true` or a vector of key names to return,
* `:timeout` -- the query timeout.
raw docstring

next.jdbc.connection

Standard implementations of get-datasource and get-connection.

Standard implementations of `get-datasource` and `get-connection`.
raw docstring

No vars found in this namespace.

next.jdbc.prepare

Mostly an implementation namespace for how PreparedStatement objects are created by the next generation java.jdbc library.

set-parameters is public and may be useful if you have a PreparedStatement that you wish to reuse and (re)set the parameters on it.

Defines the SettableParameter protocol for converting Clojure values to database-specific values.

Mostly an implementation namespace for how `PreparedStatement objects` are
created by the next generation java.jdbc library.

`set-parameters` is public and may be useful if you have a `PreparedStatement`
that you wish to reuse and (re)set the parameters on it.

Defines the `SettableParameter` protocol for converting Clojure values
to database-specific values.
raw docstring

next.jdbc.protocols

This is the extensible core of the next generation java.jdbc library.

Sourceable protocol: get-datasource -- turn something into a javax.sql.DataSource; implementations are provided for strings, hash maps (db-spec structures), and also a DataSource (which just returns itself).

Connectable protocol: get-connection -- create a new JDBC connection that should be closed when you are finished with it; implementations are provided for DataSource, PreparedStatement, and Object, on the assumption that an Object can possibly be turned into a DataSource.

Executable protocol: -execute -- given SQL and parameters, produce a 'reducible' that, when reduced, executes the SQL and produces a ResultSet that can be processed; implementations are provided for Connection, DataSource, PreparedStatement, and Object (on the assumption that an Object can be turned into a DataSource and therefore used to get a Connection).

-execute-one -- given SQL and parameters, executes the SQL and produces the first row of the ResultSet as a datafiable hash map (by default); implementations are provided for Connection, DataSource, PreparedStatement, and Object (on the assumption that an Object can be turned into a DataSource and therefore used to get a Connection).

-execute-all -- given SQL and parameters, executes the SQL and produces either a vector of datafiable hash maps from the ResultSet (default) or a vector of column names followed by vectors of row values; implementations are provided for Connection, DataSource, PreparedStatement, and Object (on the assumption that an Object can be turned into a DataSource and therefore used to get a Connection).

Preparable protocol: prepare -- given SQL and parameters, produce a PreparedStatement that can be executed (by -execute above); implementation is provided for Connection only.

Transactable protocol: -transact -- given a function (presumably containing SQL operations), run the function inside a SQL transaction; implementations are provided for Connection, DataSource, and Object (on the assumption that an Object can be turned into a DataSource).

This is the extensible core of the next generation java.jdbc library.

`Sourceable` protocol:
`get-datasource` -- turn something into a `javax.sql.DataSource`; implementations
    are provided for strings, hash maps (`db-spec` structures), and also a
    `DataSource` (which just returns itself).

`Connectable` protocol:
`get-connection` -- create a new JDBC connection that should be closed when you
    are finished with it; implementations are provided for `DataSource`,
    `PreparedStatement`, and `Object`, on the assumption that an `Object`
    can possibly be turned into a `DataSource`.

`Executable` protocol:
`-execute` -- given SQL and parameters, produce a 'reducible' that, when
    reduced, executes the SQL and produces a `ResultSet` that can be processed;
    implementations are provided for `Connection`, `DataSource`,
    `PreparedStatement`, and `Object` (on the assumption that an `Object` can be
    turned into a `DataSource` and therefore used to get a `Connection`).

`-execute-one` -- given SQL and parameters, executes the SQL and produces
    the first row of the `ResultSet` as a datafiable hash map (by default);
    implementations are provided for `Connection`, `DataSource`,
    `PreparedStatement`, and `Object` (on the assumption that an `Object` can be
    turned into a `DataSource` and therefore used to get a `Connection`).

`-execute-all` -- given SQL and parameters, executes the SQL and produces
    either a vector of datafiable hash maps from the `ResultSet` (default)
    or a vector of column names followed by vectors of row values;
    implementations are provided for `Connection`, `DataSource`,
    `PreparedStatement`, and `Object` (on the assumption that an `Object` can be
    turned into a `DataSource` and therefore used to get a `Connection`).

`Preparable` protocol:
`prepare` -- given SQL and parameters, produce a `PreparedStatement` that can
    be executed (by -execute above); implementation is provided for
    `Connection` only.

`Transactable` protocol:
`-transact` -- given a function (presumably containing SQL operations),
    run the function inside a SQL transaction; implementations are provided
    for `Connection`, `DataSource`, and `Object` (on the assumption that an
    `Object` can be turned into a `DataSource`).
raw docstring

next.jdbc.quoted

Provides functions for use with the :table-fn and :column-fn options that define how SQL entities should be quoted in strings constructed from Clojure data.

Provides functions for use with the `:table-fn` and `:column-fn` options
that define how SQL entities should be quoted in strings constructed
from Clojure data.
raw docstring

next.jdbc.result-set

An implementation of ResultSet handling functions.

Defines the following protocols:

  • DatafiableRow -- for turning a row into something datafiable
  • ReadableColumn -- to read column values by label or index
  • RowBuilder -- for materializing a row
  • ResultSetBuilder -- for materializing a result set

Also provides the default implemenations for Executable and the default datafy/nav behavior for rows from a result set.

An implementation of `ResultSet` handling functions.

Defines the following protocols:
* `DatafiableRow` -- for turning a row into something datafiable
* `ReadableColumn` -- to read column values by label or index
* `RowBuilder` -- for materializing a row
* `ResultSetBuilder` -- for materializing a result set

Also provides the default implemenations for `Executable` and
the default `datafy`/`nav` behavior for rows from a result set.
raw docstring

next.jdbc.sql

Some utility functions that make common operations easier by providing some syntactic sugar over execute!/execute-one!.

This is intended to provide a minimal level of parity with clojure.java.jdbc (insert!, update!, delete!, etc). For anything more complex, use a library like HoneySQL https://github.com/jkk/honeysql to generate SQL + parameters.

The following options are supported:

  • :table-fn -- specify a function used to convert table names (strings) to SQL entity names -- see the next.jdbc.quoted namespace for the most common quoting strategy functions,
  • :column-fn -- specify a function used to convert column names (strings) to SQL entity names -- see the next.jdbc.quoted namespace for the most common quoting strategy functions.

In addition, find-by-keys supports :order-by to add an ORDER BY clause to the generated SQL.

Some utility functions that make common operations easier by
providing some syntactic sugar over `execute!`/`execute-one!`.

This is intended to provide a minimal level of parity with
`clojure.java.jdbc` (`insert!`, `update!`, `delete!`, etc).
For anything more complex, use a library like HoneySQL
https://github.com/jkk/honeysql to generate SQL + parameters.

The following options are supported:
* `:table-fn` -- specify a function used to convert table names (strings)
    to SQL entity names -- see the `next.jdbc.quoted` namespace for the
    most common quoting strategy functions,
* `:column-fn` -- specify a function used to convert column names (strings)
    to SQL entity names -- see the `next.jdbc.quoted` namespace for the
    most common quoting strategy functions.

In addition, `find-by-keys` supports `:order-by` to add an `ORDER BY`
clause to the generated SQL.
raw docstring

next.jdbc.transaction

SQL Transaction logic.

SQL Transaction logic.
raw docstring

No vars found in this namespace.

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close