public class DefaultSQLHandler extends Object implements SQLHandler
| Constructor and Description |
|---|
DefaultSQLHandler(DataSource dataSource)
Constructs a new instance that connects to the given DataSource
|
DefaultSQLHandler(DataSource dataSource,
boolean doExecuteUpdates)
Constructs a new instance that connects to the given DataSource
|
| Modifier and Type | Method and Description |
|---|---|
void |
executeQuery(String sql)
Executes the given query.
|
int |
executeUpdate(String sql)
Executes the given statement.
|
int |
executeUpdateAndCommit(String sql)
Executes the given statement and commits.
|
boolean |
exists(String sql)
Returns true if the query returned a record.
|
DataSource |
getDataSource() |
long |
getItemAsLong(String sql)
Returns the long extracted from the result of the given query.
|
String |
getItemAsString(String sql)
Returns the value extracted from the result of the given query.
|
Set<String> |
getItemsAsStringSet(String sql)
Returns the items extracted from the result of the given query.
|
boolean |
isDoExecuteUpdates() |
public DefaultSQLHandler(DataSource dataSource)
dataSource - The data source, not nullpublic DefaultSQLHandler(DataSource dataSource, boolean doExecuteUpdates)
dataSource - The data source, not nulldoExecuteUpdates - Boolean indicating whether updates should effectively be executed on the underlying
databasepublic int executeUpdate(String sql)
SQLHandlerexecuteUpdate in interface SQLHandlersql - The sql statementpublic void executeQuery(String sql)
SQLHandlerexecuteQuery in interface SQLHandlersql - The sql querypublic int executeUpdateAndCommit(String sql)
SQLHandlerexecuteUpdateAndCommit in interface SQLHandlersql - The sql statementpublic long getItemAsLong(String sql)
SQLHandlerUnitilsException
is thrown.getItemAsLong in interface SQLHandlersql - The sql string for retrieving the itemspublic String getItemAsString(String sql)
SQLHandlerUnitilsException
is thrown.getItemAsString in interface SQLHandlersql - The sql string for retrieving the itemspublic Set<String> getItemsAsStringSet(String sql)
SQLHandlergetItemsAsStringSet in interface SQLHandlersql - The sql string for retrieving the itemspublic boolean exists(String sql)
SQLHandlerexists in interface SQLHandlersql - The sql string for checking the existencepublic DataSource getDataSource()
getDataSource in interface SQLHandlerpublic boolean isDoExecuteUpdates()
isDoExecuteUpdates in interface SQLHandlerCopyright © 2016. All Rights Reserved.