Begins a database transaction.
Begins a database transaction.
Using this method is a preferred way of starting a transaction, using SQL statements to manage transaction state may lead to undefined behavior.
After the operation takes longer time than timeout
, operation will be
aborted. Note however, that it may not be feasible to abort the operation
immediately.
Returned future can fail with:
Commits a database transaction.
Commits a database transaction.
Using this method is a preferred way of committing a transaction, using SQL statements to manage transaction state may lead to undefined behavior.
After the operation takes longer time than timeout
, operation will be
aborted. Note however, that it may not be feasible to abort the operation
immediately.
Returned future can fail with:
Releases the connection and underlying resources regardless of whether the connection is currently in use or not.
Releases the connection and underlying resources regardless of whether the connection is currently in use or not.
After calling this method no future operations on the instance are allowed.
Returned future can fail with:
Releases the connection and underlying resources.
Releases the connection and underlying resources.
Only idle connections can be released using this method. To forcibly release the connection use forceRelease method.
After calling this method no future operations on the instance are allowed.
Returned future can fail with:
Rolls back a database transaction.
Rolls back a database transaction.
Using this method is a preferred way of rolling back a transaction, using SQL statements to manage transaction state may lead to undefined behavior.
After the operation takes longer time than timeout
, operation will be
aborted. Note however, that it may not be feasible to abort the operation
immediately.
Returned future can fail with:
Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.
Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.
It's a shortcut for calling statement
and then bind
.
SqlWithParams parameter instance is meant to be constructed using sql
string interpolator, for example:
import io.rdbc.sapi.Interpolators._ val x = 1 val y = 10 val stmt = conn.statement(sql"select * from table where colx > $x and coly < $y")
Throws:
Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.
Returns a ExecutableStatement instance bound to this connection that represents any parametrized SQL statement.
It's a shortcut for calling statement
and then bind
.
SqlWithParams parameter instance is meant to be constructed using sql
string interpolator, for example:
import io.rdbc.sapi.Interpolators._ val x = 1 val y = 10 val stmt = conn.statement(sql"select * from table where colx > $x and coly < $y")
Throws:
Returns a Statement instance bound to this connection that represents any SQL statement.
Returns a Statement instance bound to this connection that represents any SQL statement.
For syntax of statement parametrization see a Connection documentation.
Throws:
Returns a Statement instance bound to this connection that represents any SQL statement.
Returns a Statement instance bound to this connection that represents any SQL statement.
For syntax of statement parametrization see a Connection documentation.
Throws:
Checks whether the connection is still usable.
Checks whether the connection is still usable.
If checking takes longer than timeout
, connection is considered unusable.
Future of true
iff connection is usable, false
otherwise
Returns a future that is complete when this connection is idle and ready for accepting queries.
Executes a function in a context of a transaction.
Executes a function in a context of a transaction.
Executes a function (which can be passed as a code block) in a context of a transaction. Before the function is executed, transaction is started. After the function finishes, transaction is committed in case of a success and rolled back in case of a failure.
Because managing transaction state requires invoking functions that require specifying a timeout, this function requires an implicit timeout instance.
Executes a future-returning function in a context of a transaction.
Executes a future-returning function in a context of a transaction.
Executes a function (which can be passed as a code block) in a context of a transaction. Before the function is executed, transaction is started. After the function finishes, transaction is committed in case of a success and rolled back in case of a failure.
Because managing transaction state requires invoking functions that require specifying a timeout, this function requires an implicit timeout instance.
Represents a database connection (session).
Instances of implementations of this trait can be obtained using a ConnectionFactory. When clients are done with the connection, they are required to call a
release
method co clean up resources such as open sockets.Invoking any method of this trait when any previous operation has not completed yet is not allowed. Operation is considered complete when a resulting Future completes.
Transaction management has to be done using
beginTx
,commitTx
androllbackTx
methods. Using SQL statements to manage transaction state is not allowed.SqlWithParams instances passed to
Connection
's methods can be created usingsql
string interpolator, for example:Alternatively, when bare Strings are used as SQL statements, parameters are specified by name. Parameter name is an alphanumeric string starting with a letter, prefixed with a colon. Example: