| org.sakaiproject.db.api.SqlService
All known Subclasses: org.sakaiproject.db.impl.BasicSqlService,
SqlService | public interface SqlService (Code) | |
SqlService provides access to pooled Connections to Sql databases.
The Connection objects managed by this service are standard java.sql.Connection objects.
|
Method Summary | |
Connection | borrowConnection() Access an available or newly created Connection from the default pool. | void | dbCancel(Connection conn) Cancel the update that was locked on this connection. | Long | dbInsert(Connection callerConnection, String sql, Object[] fields, String autoColumn) Execute the "insert" sql, returning a possible auto-update field Long value
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: callerConnection - The connection to use. Parameters: autoColumn - The name of the db column that will have auto-update - we will return the value used (leave null to disable this feature). | Long | dbInsert(Connection callerConnection, String sql, Object[] fields, String autoColumn, InputStream last, int lastLength) Execute the "insert" sql, returning a possible auto-update field Long value, with an additional stream parameter.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: callerConnection - The connection to use. Parameters: autoColumn - The name of the db column that will have auto-update - we will return the value used (leave null to disable this feature). Parameters: last - An input stream to add as the last parameter. Parameters: lastLength - The number of bytes in the input stream to write. | List | dbRead(String sql) Read a single field from the db, from multiple records, returned as string[], one per record.
Parameters: sql - The sql statement. | List | dbRead(String sql, Object[] fields, SqlReader reader) Process a query, filling in with fields, and return the results as a List, one per record read. | List | dbRead(Connection conn, String sql, Object[] fields, SqlReader reader) Process a query, filling in with fields, and return the results as a List, one per record read. | void | dbReadBinary(String sql, Object[] fields, byte[] value) Read a single field from the db, from multiple record - concatenating the binary values into value. | void | dbReadBinary(Connection conn, String sql, Object[] fields, byte[] value) Read a single field from the db, from multiple record - concatenating the binary values into value. | InputStream | dbReadBinary(String sql, Object[] fields, boolean big) Read a single field / record from the db, returning a stream on the result record / field. | void | dbReadBlobAndUpdate(String sql, byte[] content) Read a single field BLOB from the db from one record, and update it's bytes with content. | Connection | dbReadLock(String sql, StringBuffer field) Read a single field from the db, from a single record, return the value found, and lock for update.
Parameters: sql - The sql statement. Parameters: field - A StringBuffer that will be filled with the field. | void | dbUpdateCommit(String sql, Object[] fields, String var, Connection conn) Commit the update that was locked on this connection. | boolean | dbWrite(String sql) Execute the "write" sql - no response.
Parameters: sql - The sql statement. | boolean | dbWrite(String sql, String var) Execute the "write" sql - no response. | boolean | dbWrite(String sql, Object[] fields) Execute the "write" sql - no response, using a set of fields from an array.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. | boolean | dbWrite(Connection connection, String sql, Object[] fields) Execute the "write" sql - no response, using a set of fields from an array and a given connection.
Parameters: connection - The connection to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. | boolean | dbWrite(String sql, Object[] fields, String lastField) Execute the "write" sql - no response, using a set of fields from an array plus one more as params.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: lastField - The value to bind to the last parameter in the sql statement. | boolean | dbWriteBinary(String sql, Object[] fields, byte[] var, int offset, int len) Execute the "write" sql - no response. | boolean | dbWriteFailQuiet(Connection connection, String sql, Object[] fields) Execute the "write" sql - no response, using a set of fields from an array and a given connection logging no errors on failure.
Parameters: connection - The connection to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. | void | ddl(ClassLoader loader, String resource) Load and run the named file using the given class loader, as a ddl check / create. | String | getBooleanConstant(boolean value) Get the SQL statement constant for a Boolean or Bit field for this value.
Parameters: value - The value. | GregorianCalendar | getCal() Access the calendar used in processing Time objects for Sql. | Long | getNextSequence(String tableName, Connection conn) Get the next value from this sequence, for those technologies that support sequences. | String | getVendor() | void | returnConnection(Connection conn) Release a database connection.
Parameters: conn - The connetion to release. | boolean | transact(Runnable callback, String tag) Run some code in a transaction. |
borrowConnection | Connection borrowConnection() throws SQLException(Code) | | Access an available or newly created Connection from the default pool. Will wait a while until one is available.
The Connection object. throws: SQLException - if a connection cannot be delivered. |
dbCancel | void dbCancel(Connection conn)(Code) | | Cancel the update that was locked on this connection.
Parameters: conn - The database connection on which the lock was gained. |
dbInsert | Long dbInsert(Connection callerConnection, String sql, Object[] fields, String autoColumn)(Code) | | Execute the "insert" sql, returning a possible auto-update field Long value
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: callerConnection - The connection to use. Parameters: autoColumn - The name of the db column that will have auto-update - we will return the value used (leave null to disable this feature). The auto-update value, or null |
dbInsert | Long dbInsert(Connection callerConnection, String sql, Object[] fields, String autoColumn, InputStream last, int lastLength)(Code) | | Execute the "insert" sql, returning a possible auto-update field Long value, with an additional stream parameter.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: callerConnection - The connection to use. Parameters: autoColumn - The name of the db column that will have auto-update - we will return the value used (leave null to disable this feature). Parameters: last - An input stream to add as the last parameter. Parameters: lastLength - The number of bytes in the input stream to write. The auto-update value, or null |
dbRead | List dbRead(String sql)(Code) | | Read a single field from the db, from multiple records, returned as string[], one per record.
Parameters: sql - The sql statement. The List of Strings of single fields of the record found, or empty if none found. |
dbRead | List dbRead(String sql, Object[] fields, SqlReader reader)(Code) | | Process a query, filling in with fields, and return the results as a List, one per record read. If a reader is provided, it will be called for each record to prepare the Object placed into the List. Otherwise, the first field of each record, as a
String, will be placed in the list.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: reader - The reader object to read each record. The List of things read, one per record. |
dbRead | List dbRead(Connection conn, String sql, Object[] fields, SqlReader reader)(Code) | | Process a query, filling in with fields, and return the results as a List, one per record read. If a reader is provided, it will be called for each record to prepare the Object placed into the List. Otherwise, the first field of each record, as a
String, will be placed in the list.
Parameters: conn - The db connection object to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: reader - The reader object to read each record. The List of things read, one per record. |
dbReadBinary | void dbReadBinary(String sql, Object[] fields, byte[] value)(Code) | | Read a single field from the db, from multiple record - concatenating the binary values into value.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: value - The array of bytes to fill with the value read from the db. |
dbReadBinary | void dbReadBinary(Connection conn, String sql, Object[] fields, byte[] value)(Code) | | Read a single field from the db, from multiple record - concatenating the binary values into value.
Parameters: conn - The optional db connection object to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: value - The array of bytes to fill with the value read from the db. |
dbReadBinary | InputStream dbReadBinary(String sql, Object[] fields, boolean big) throws ServerOverloadException(Code) | | Read a single field / record from the db, returning a stream on the result record / field. The stream holds the conection open - so it must be closed or finalized quickly!
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: big - If true, the read is expected to be potentially large. throws: ServerOverloadException - if the read cannot complete due to lack of a free connection (if wait is false) |
dbReadBlobAndUpdate | void dbReadBlobAndUpdate(String sql, byte[] content)(Code) | | Read a single field BLOB from the db from one record, and update it's bytes with content.
Parameters: sql - The sql statement to select the BLOB. Parameters: content - The new bytes for the BLOB. |
dbReadLock | Connection dbReadLock(String sql, StringBuffer field)(Code) | | Read a single field from the db, from a single record, return the value found, and lock for update.
Parameters: sql - The sql statement. Parameters: field - A StringBuffer that will be filled with the field. The Connection holding the lock. |
dbUpdateCommit | void dbUpdateCommit(String sql, Object[] fields, String var, Connection conn)(Code) | | Commit the update that was locked on this connection.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: var - The value to bind to the last parameter in the sql statement. Parameters: conn - The database connection on which the lock was gained. |
dbWrite | boolean dbWrite(String sql)(Code) | | Execute the "write" sql - no response.
Parameters: sql - The sql statement. true if successful, false if not. |
dbWrite | boolean dbWrite(String sql, String var)(Code) | | Execute the "write" sql - no response. a long field is set to "?" - fill it in with var
Parameters: sql - The sql statement. Parameters: var - The value to bind to the first parameter in the sql statement. true if successful, false if not. |
dbWrite | boolean dbWrite(String sql, Object[] fields)(Code) | | Execute the "write" sql - no response, using a set of fields from an array.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. true if successful, false if not. |
dbWrite | boolean dbWrite(Connection connection, String sql, Object[] fields)(Code) | | Execute the "write" sql - no response, using a set of fields from an array and a given connection.
Parameters: connection - The connection to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. true if successful, false if not. |
dbWrite | boolean dbWrite(String sql, Object[] fields, String lastField)(Code) | | Execute the "write" sql - no response, using a set of fields from an array plus one more as params.
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: lastField - The value to bind to the last parameter in the sql statement. true if successful, false if not. |
dbWriteBinary | boolean dbWriteBinary(String sql, Object[] fields, byte[] var, int offset, int len)(Code) | | Execute the "write" sql - no response. a long binary field is set to "?" - fill it in with var
Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. Parameters: var - The value to bind to the last parameter in the sql statement. Parameters: offset - The start within the var to write Parameters: len - The number of bytes of var, starting with index, to write true if successful, false if not. |
dbWriteFailQuiet | boolean dbWriteFailQuiet(Connection connection, String sql, Object[] fields)(Code) | | Execute the "write" sql - no response, using a set of fields from an array and a given connection logging no errors on failure.
Parameters: connection - The connection to use. Parameters: sql - The sql statement. Parameters: fields - The array of fields for parameters. true if successful, false if not. |
ddl | void ddl(ClassLoader loader, String resource)(Code) | | Load and run the named file using the given class loader, as a ddl check / create. The first non-comment ('--') line will be run, and if successfull, all other non-comment lines will be run. SQL statements must be on a single line, and may have ';'
terminators.
Parameters: loader - The ClassLoader used to load the resource. Parameters: resource - The path name to the resource - vender string and .sql will be added |
getBooleanConstant | String getBooleanConstant(boolean value)(Code) | | Get the SQL statement constant for a Boolean or Bit field for this value.
Parameters: value - The value. The SQL statement constant for a Boolean or Bit field for this value. |
getCal | GregorianCalendar getCal()(Code) | | Access the calendar used in processing Time objects for Sql.
The calendar used in processing Time objects for Sql. |
getNextSequence | Long getNextSequence(String tableName, Connection conn)(Code) | | Get the next value from this sequence, for those technologies that support sequences. For the others, return null.
Parameters: tableName - The sequence table name Parameters: conn - The database connection to use (it will use a new one if null). The Integer value that is the next sequence, or null if sequences are not supported |
getVendor | String getVendor()(Code) | | a string indicating the database vendor - "oracle" or "mysql" or "hsqldb". |
returnConnection | void returnConnection(Connection conn)(Code) | | Release a database connection.
Parameters: conn - The connetion to release. If null or not one of ours, ignored. |
transact | boolean transact(Runnable callback, String tag)(Code) | | Run some code in a transaction. The code is callback. Any calls to this service will be done within the transaction if they don't supply their
own connection.
If the transaction fails due to a deadlock, it will be retried a number of times.
Parameters: callback - The code to run. Parameters: tag - A string to use in logging failure to identify the transaction. true if all went well. The SqlServiceDeadlockException will be thrown if we end up failing due to a deadlock, and theSqlServiceUniqueViolation. |
|
|