Interface DatabaseConnection
- 
- All Superinterfaces:
- AutoCloseable
 
 public interface DatabaseConnection extends AutoCloseable A Database Connection. See Examples.java for examples.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()voidexecuteQuery(String sql, Object[] parameters, ResultSetCallback callback)Execute a query and process the result using a callback.ResultSetexecuteQueryAutoClose(String sql, Object... parameters)Execute a query and return the result set, the result set will be automatically closed if the user does not do so.intexecuteUpdate(String sql, Object... parameters)Execute an update and return the number of rows updated.booleangetCloseOnReturn()Will the connection be physically closed, or returned to the pool?ConnectiongetWrappedConnectionAutoClose()Get the underlying connection.voidsetCloseOnReturn()Sets closeOnReturn, meaning that the connection is physically closed, rather than returned to the connection pool.
 
- 
- 
- 
Method Detail- 
closevoid close() throws SQLException- Specified by:
- closein interface- AutoCloseable
- Throws:
- SQLException
 
 - 
executeQueryvoid executeQuery(String sql, Object[] parameters, ResultSetCallback callback) throws SQLException Execute a query and process the result using a callback.- Parameters:
- sql- the SQL
- parameters- The parameters, may be null for no parameters, may contain- OutputParameterand- Nullobjects, if an array is passed no element may be null.
- callback- the callback to pass the ResultSet to.
- Throws:
- SQLException- if an error occurs.
- See Also:
- for an example
 
 - 
executeQueryAutoCloseResultSet executeQueryAutoClose(String sql, Object... parameters) throws SQLException Execute a query and return the result set, the result set will be automatically closed if the user does not do so. You may call close() on the result early.- Parameters:
- sql- the SQL
- parameters- The parameters may contain- OutputParameterand- Nullobjects, if an array is passed no element may be null.
- Returns:
- the result set.
- Throws:
- SQLException- if an error occurs.
- See Also:
- for an example
 
 - 
executeUpdateint executeUpdate(String sql, Object... parameters) throws SQLException Execute an update and return the number of rows updated.- Parameters:
- sql- the SQL
- parameters- The parameters may contain- OutputParameterand- Nullobjects, if an array is passed no element may be null.
- Returns:
- the number of rows updated.
- Throws:
- SQLException- if an error occurs.
- See Also:
- for an example
 
 - 
getWrappedConnectionAutoCloseConnection getWrappedConnectionAutoClose() throws SQLException Get the underlying connection. This is wrapped using dynamic proxies to ensure resources are closed correctly. This connection may be cast toUnwrapin order to be unwrapped. Note that unwrapping a connection is done at the customer's own risk and means that no support will be provided for resource management issues.- Returns:
- the connection.
- Throws:
- SQLException- if an error occurs.
- See Also:
- for an example
 
 - 
getCloseOnReturnboolean getCloseOnReturn() Will the connection be physically closed, or returned to the pool?- Returns:
- true, when the connection is physically closed and not returned to the pool, when the connection is closed. False, when the connection is returned to the pool, when the connection is closed.
 
 - 
setCloseOnReturnvoid setCloseOnReturn() Sets closeOnReturn, meaning that the connection is physically closed, rather than returned to the connection pool.
 
- 
 
-