org.unitils.core.dbsupport
Interface SQLHandler

All Known Implementing Classes:
DefaultSQLHandler

public interface SQLHandler


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()
           
 

Method Detail

executeUpdate

int executeUpdate(String sql)
Executes the given statement.

Parameters:
sql - The sql statement
Returns:
The nr of updates

executeQuery

void executeQuery(String sql)
Executes the given query. Note that no result is returned: this method is only useful in case you want to execute a query that has some desired side-effect (in fact, this method perfoms an update which is disguised as a query ;-) )

Parameters:
sql - The sql query

executeUpdateAndCommit

int executeUpdateAndCommit(String sql)
Executes the given statement and commits.

Parameters:
sql - The sql statement
Returns:
The nr of updates

getItemAsLong

long getItemAsLong(String sql)
Returns the long extracted from the result of the given query. If no value is found, a UnitilsException is thrown.

Parameters:
sql - The sql string for retrieving the items
Returns:
The long item value

getItemAsString

String getItemAsString(String sql)
Returns the value extracted from the result of the given query. If no value is found, a UnitilsException is thrown.

Parameters:
sql - The sql string for retrieving the items
Returns:
The string item value

getItemsAsStringSet

Set<String> getItemsAsStringSet(String sql)
Returns the items extracted from the result of the given query.

Parameters:
sql - The sql string for retrieving the items
Returns:
The items, not null

exists

boolean exists(String sql)
Returns true if the query returned a record.

Parameters:
sql - The sql string for checking the existence
Returns:
True if a record was returned

getDataSource

DataSource getDataSource()
Returns:
The DataSource

isDoExecuteUpdates

boolean isDoExecuteUpdates()
Returns:
Whether updates are executed on the database or not


Copyright © 2011. All Rights Reserved.