|
||||||||||
| 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(javax.sql.DataSource dataSource)
Constructs a new instance that connects to the given DataSource |
|
DefaultSQLHandler(javax.sql.DataSource dataSource,
boolean doExecuteUpdates)
Constructs a new instance that connects to the given DataSource |
|
| Method Summary | |
|---|---|
void |
executeQuery(java.lang.String sql)
Executes the given query. |
int |
executeUpdate(java.lang.String sql)
Executes the given statement. |
int |
executeUpdateAndCommit(java.lang.String sql)
Executes the given statement and commits. |
boolean |
exists(java.lang.String sql)
Returns true if the query returned a record. |
javax.sql.DataSource |
getDataSource()
|
long |
getItemAsLong(java.lang.String sql)
Returns the long extracted from the result of the given query. |
java.lang.String |
getItemAsString(java.lang.String sql)
Returns the value extracted from the result of the given query. |
java.util.Set<java.lang.String> |
getItemsAsStringSet(java.lang.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(javax.sql.DataSource dataSource)
dataSource - The data source, not null
public DefaultSQLHandler(javax.sql.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(java.lang.String sql)
SQLHandler
executeUpdate in interface SQLHandlersql - The sql statement
public void executeQuery(java.lang.String sql)
SQLHandler
executeQuery in interface SQLHandlersql - The sql querypublic int executeUpdateAndCommit(java.lang.String sql)
SQLHandler
executeUpdateAndCommit in interface SQLHandlersql - The sql statement
public long getItemAsLong(java.lang.String sql)
SQLHandlerUnitilsException
is thrown.
getItemAsLong in interface SQLHandlersql - The sql string for retrieving the items
public java.lang.String getItemAsString(java.lang.String sql)
SQLHandlerUnitilsException
is thrown.
getItemAsString in interface SQLHandlersql - The sql string for retrieving the items
public java.util.Set<java.lang.String> getItemsAsStringSet(java.lang.String sql)
SQLHandler
getItemsAsStringSet in interface SQLHandlersql - The sql string for retrieving the items
public boolean exists(java.lang.String sql)
SQLHandler
exists in interface SQLHandlersql - The sql string for checking the existence
public javax.sql.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 | |||||||||