|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.core.dbsupport.DefaultSQLHandler
public class DefaultSQLHandler
Class to which database updates and queries are passed. Is in fact a utility class, but is a concrete instance to enable decorating it or switching it with another implementation, allowing things like a dry run, creating a script file or logging updates to a log file or database table.
| Constructor Summary | |
|---|---|
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 |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultSQLHandler(DataSource dataSource)
dataSource - The data source, not null
public DefaultSQLHandler(DataSource dataSource,
boolean doExecuteUpdates)
dataSource - The data source, not nulldoExecuteUpdates - Boolean indicating whether updates should effectively be executed on the underlying
database| Method Detail |
|---|
public int executeUpdate(String sql)
SQLHandler
executeUpdate in interface SQLHandlersql - The sql statement
public void executeQuery(String sql)
SQLHandler
executeQuery in interface SQLHandlersql - The sql querypublic int executeUpdateAndCommit(String sql)
SQLHandler
executeUpdateAndCommit in interface SQLHandlersql - The sql statement
public long getItemAsLong(String sql)
SQLHandlerUnitilsException
is thrown.
getItemAsLong in interface SQLHandlersql - The sql string for retrieving the items
public String getItemAsString(String sql)
SQLHandlerUnitilsException
is thrown.
getItemAsString in interface SQLHandlersql - The sql string for retrieving the items
public Set<String> getItemsAsStringSet(String sql)
SQLHandler
getItemsAsStringSet in interface SQLHandlersql - The sql string for retrieving the items
public boolean exists(String sql)
SQLHandler
exists in interface SQLHandlersql - The sql string for checking the existence
public DataSource getDataSource()
getDataSource in interface SQLHandlerpublic boolean isDoExecuteUpdates()
isDoExecuteUpdates in interface SQLHandler
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||