An object that exposes operations for executing SQL DML or DDL queries against JDBC connections obtained by calling a given function.

By: Enrique Zamudio, Gavin King

no subtypes hierarchy

Initializer
Sql(Connection newConnection())
Parameters:
  • newConnection

    Obtain a JDBC connection.

Inherited Attributes
Attributes inherited from: Object
Methods
transactionSource Codeshared void transaction(Boolean do())

Execute the given function in a new database transaction. If the function returns false, or if an exception is thrown by the function, the transaction will be rolled back.

Inherited Methods
Methods inherited from: Object
Nested Classes
CallSource Codeshared Call

Define a SQL callable statement, with parameters indicated by ? placeholders. Intended for calling database functions or stored procedures that update or delete rows.

InsertSource Codeshared Insert

Define a SQL insert statement with parameters indicated by ? placeholders.

SelectSource Codeshared Select

Define a SQL select query with parameters indicated by ? placeholders.

StatementSource Codeshared Statement

Define a SQL statement with parameters indicated by ? placeholders.

TransactionSource Codeshared Transaction

Begin a new database transaction. If Transaction.rollbackOnly() is called, or if an exception propagates out of try, the transaction will be rolled back. Otherwise, the transaction will be committed.

Should be instantiated using try:

try (tx = sql.Transaction()) {
    //do work here
    if (something) {
        tx.rollbackOnly();
    }
}
UpdateSource Codeshared Update

Define a SQL update or delete statement with parameters indicated by ? placeholders.