groovy.gdo
Class Sql

java.lang.Object
  |
  +--groovy.gdo.Sql
Direct Known Subclasses:
DataSet

public class Sql
extends Object

Represents an extent of objects

Version:
$Revision: 1.6 $
Author:
Chris Stevenson, James Strachan

Field Summary
protected  Logger log
           
 
Constructor Summary
Sql(DataSource dataSource)
           
 
Method Summary
protected  String asSql(groovy.lang.GString gstring)
           
 int call(groovy.lang.GString gstring)
          Performs a stored procedure call with the given parameters
 int call(String sql)
          Performs a stored procedure call
 int call(String sql, List params)
          Performs a stored procedure call with the given parameters
protected  void closeResources(Connection connection, Statement statement)
           
protected  void closeResources(Connection connection, Statement statement, ResultSet results)
           
protected  Connection createConnection()
           
 groovy.gdo.DataSet dataSet(String table)
           
 boolean execute(groovy.lang.GString gstring)
          Executes the given SQL with embedded expressions inside
 boolean execute(String sql)
          Executes the given piece of SQL
 boolean execute(String sql, List params)
          Executes the given piece of SQL with parameters
 DataSource getDataSource()
           
protected  List getParameters(groovy.lang.GString gstring)
           
 void query(groovy.lang.GString gstring, groovy.lang.Closure closure)
          Performs the given SQL query calling the closure with the result set
 void query(String sql, groovy.lang.Closure closure)
          Performs the given SQL query calling the closure with the result set
 void query(String sql, List params, groovy.lang.Closure closure)
          Performs the given SQL query with parameters calling the closure with the result set
 void queryEach(groovy.lang.GString gstring, groovy.lang.Closure closure)
          Performs the given SQL query calling the closure with the result set
 void queryEach(String sql, groovy.lang.Closure closure)
          Performs the given SQL query calling the closure with each row of the result set
 void queryEach(String sql, List params, groovy.lang.Closure closure)
          Performs the given SQL query calling the closure with the result set
protected  void setObject(PreparedStatement statement, int i, Object value)
          Strategy method allowing derived classes to handle types differently such as for CLOBs etc.
protected  void setParameters(List params, PreparedStatement statement)
          Appends the parameters to the given statement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected Logger log
Constructor Detail

Sql

public Sql(DataSource dataSource)
Method Detail

dataSet

public groovy.gdo.DataSet dataSet(String table)

query

public void query(String sql,
                  groovy.lang.Closure closure)
           throws SQLException
Performs the given SQL query calling the closure with the result set

SQLException

query

public void query(String sql,
                  List params,
                  groovy.lang.Closure closure)
           throws SQLException
Performs the given SQL query with parameters calling the closure with the result set

SQLException

query

public void query(groovy.lang.GString gstring,
                  groovy.lang.Closure closure)
           throws SQLException
Performs the given SQL query calling the closure with the result set

SQLException

queryEach

public void queryEach(String sql,
                      groovy.lang.Closure closure)
               throws SQLException
Performs the given SQL query calling the closure with each row of the result set

SQLException

queryEach

public void queryEach(String sql,
                      List params,
                      groovy.lang.Closure closure)
               throws SQLException
Performs the given SQL query calling the closure with the result set

SQLException

queryEach

public void queryEach(groovy.lang.GString gstring,
                      groovy.lang.Closure closure)
               throws SQLException
Performs the given SQL query calling the closure with the result set

SQLException

execute

public boolean execute(String sql)
                throws SQLException
Executes the given piece of SQL

SQLException

execute

public boolean execute(String sql,
                       List params)
                throws SQLException
Executes the given piece of SQL with parameters

SQLException

execute

public boolean execute(groovy.lang.GString gstring)
                throws SQLException
Executes the given SQL with embedded expressions inside

SQLException

call

public int call(String sql)
         throws Exception
Performs a stored procedure call

Exception

call

public int call(String sql,
                List params)
         throws Exception
Performs a stored procedure call with the given parameters

Exception

call

public int call(groovy.lang.GString gstring)
         throws Exception
Performs a stored procedure call with the given parameters

Exception

getDataSource

public DataSource getDataSource()

asSql

protected String asSql(groovy.lang.GString gstring)
Returns:
the SQL version of the given query using ? instead of any parameter

getParameters

protected List getParameters(groovy.lang.GString gstring)
Returns:
extracts the parameters from the expression as a List

setParameters

protected void setParameters(List params,
                             PreparedStatement statement)
                      throws SQLException
Appends the parameters to the given statement

SQLException

setObject

protected void setObject(PreparedStatement statement,
                         int i,
                         Object value)
                  throws SQLException
Strategy method allowing derived classes to handle types differently such as for CLOBs etc.

SQLException

createConnection

protected Connection createConnection()
                               throws SQLException
SQLException

closeResources

protected void closeResources(Connection connection,
                              Statement statement,
                              ResultSet results)

closeResources

protected void closeResources(Connection connection,
                              Statement statement)


Copyright © 2003 The Codehaus. All Rights Reserved.