Package groovy.sql
Class Sql.AbstractQueryCommand
java.lang.Object
groovy.sql.Sql.AbstractQueryCommand
- Enclosing class:
- Sql
protected abstract class Sql.AbstractQueryCommand
extends java.lang.Object
- 
Field Summary
- 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractQueryCommand(java.lang.String sql)
- 
Method SummaryModifier and Type Method Description protected voidcloseResources()After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.protected voidcloseResources(java.sql.ResultSet rs)After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.protected java.sql.ResultSetexecute()Execute the command that's defined by the subclass following the Command pattern.protected intgetMaxRows()Get the maximum number of rows to return in the ResultSetprotected abstract java.sql.ResultSetrunQuery(java.sql.Connection connection)Perform the query.protected voidsetMaxRows(int maxRows)Set the maximum number of rows to return in the ResultSetMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Field Details- 
sqlprotected final java.lang.String sql
- 
statementprotected java.sql.Statement statement
 
- 
- 
Constructor Details- 
AbstractQueryCommandprotected AbstractQueryCommand(java.lang.String sql)
 
- 
- 
Method Details- 
executeprotected final java.sql.ResultSet execute() throws java.sql.SQLExceptionExecute the command that's defined by the subclass following the Command pattern. Specialized parameters are held in the command instances.- Returns:
- ResultSet from executing a query
- Throws:
- java.sql.SQLException- if a database error occurs
 
- 
closeResourcesprotected final void closeResources()After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.
- 
closeResourcesprotected final void closeResources(java.sql.ResultSet rs)After performing the execute operation and making use of its return, it's necessary to free the resources allocated for the statement.- Parameters:
- rs- allows the caller to conveniently close its resource as well
 
- 
runQueryprotected abstract java.sql.ResultSet runQuery(java.sql.Connection connection) throws java.sql.SQLExceptionPerform the query. Must set statement field so that the main (execute()) method can clean up. This is the method that encloses the variant part of the code.- Parameters:
- connection- the connection to use
- Returns:
- ResultSet from an executeQuery method.
- Throws:
- java.sql.SQLException- if a database error occurs
 
- 
setMaxRowsprotected void setMaxRows(int maxRows)Set the maximum number of rows to return in the ResultSet- Parameters:
- maxRows- the maximum number of rows
 
- 
getMaxRowsprotected int getMaxRows()Get the maximum number of rows to return in the ResultSet- Returns:
- the maximum number of rows
 
 
-