|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.sql.Sql
Represents an extent of objects
Field Summary | |
protected java.util.logging.Logger |
log
|
Constructor Summary | |
Sql(java.sql.Connection connection)
Construts an SQL instance using the given Connection. |
|
Sql(javax.sql.DataSource dataSource)
Constructs an SQL instance using the given DataSource. |
|
Sql(Sql parent)
|
Method Summary | |
protected java.lang.String |
asSql(GString gstring)
|
int |
call(GString gstring)
Performs a stored procedure call with the given parameters |
int |
call(java.lang.String sql)
Performs a stored procedure call |
int |
call(java.lang.String sql,
java.util.List params)
Performs a stored procedure call with the given parameters |
void |
close()
If this SQL object was created with a Connection then this method closes the connection. |
protected void |
closeResources(java.sql.Connection connection,
java.sql.Statement statement)
|
protected void |
closeResources(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet results)
|
protected java.sql.Connection |
createConnection()
|
DataSet |
dataSet(java.lang.Class type)
|
DataSet |
dataSet(java.lang.String table)
|
void |
eachRow(GString gstring,
Closure closure)
Performs the given SQL query calling the closure with the result set |
void |
eachRow(java.lang.String sql,
Closure closure)
Performs the given SQL query calling the closure with each row of the result set |
void |
eachRow(java.lang.String sql,
java.util.List params,
Closure closure)
Performs the given SQL query calling the closure with the result set |
boolean |
execute(GString gstring)
Executes the given SQL with embedded expressions inside |
boolean |
execute(java.lang.String sql)
Executes the given piece of SQL |
boolean |
execute(java.lang.String sql,
java.util.List params)
Executes the given piece of SQL with parameters |
int |
executeUpdate(GString gstring)
Executes the given SQL update with embedded expressions inside |
int |
executeUpdate(java.lang.String sql)
Executes the given SQL update |
int |
executeUpdate(java.lang.String sql,
java.util.List params)
Executes the given SQL update with parameters |
protected int |
findWhereKeyword(java.lang.String sql)
Find the first 'where' keyword in the sql. |
javax.sql.DataSource |
getDataSource()
|
protected java.util.List |
getParameters(GString gstring)
|
static void |
loadDriver(java.lang.String driverClassName)
Attempts to load the JDBC driver on the thread, current or system class loaders |
static Sql |
newInstance(java.lang.String url)
A helper method which creates a new Sql instance from a JDBC connection URL |
static Sql |
newInstance(java.lang.String url,
java.util.Properties properties)
A helper method which creates a new Sql instance from a JDBC connection URL |
static Sql |
newInstance(java.lang.String url,
java.util.Properties properties,
java.lang.String driverClassName)
A helper method which creates a new Sql instance from a JDBC connection URL and driver class name |
static Sql |
newInstance(java.lang.String url,
java.lang.String driverClassName)
A helper method which creates a new Sql instance from a JDBC connection URL and driver class name |
static Sql |
newInstance(java.lang.String url,
java.lang.String user,
java.lang.String password)
A helper method which creates a new Sql instance from a JDBC connection URL, username and password |
static Sql |
newInstance(java.lang.String url,
java.lang.String user,
java.lang.String password,
java.lang.String driverClassName)
A helper method which creates a new Sql instance from a JDBC connection URL, username, password and driver class name |
protected java.lang.String |
nullify(java.lang.String sql)
replace ?'"? references with NULLish |
void |
query(GString gstring,
Closure closure)
Performs the given SQL query calling the closure with the result set |
void |
query(java.lang.String sql,
Closure closure)
Performs the given SQL query calling the closure with the result set |
void |
query(java.lang.String sql,
java.util.List params,
Closure closure)
Performs the given SQL query with parameters calling the closure with the result set |
void |
queryEach(GString gstring,
Closure closure)
Deprecated. please use eachRow instead |
void |
queryEach(java.lang.String sql,
Closure closure)
Deprecated. please use eachRow instead |
void |
queryEach(java.lang.String sql,
java.util.List params,
Closure closure)
Deprecated. please use eachRow instead |
protected void |
setObject(java.sql.PreparedStatement statement,
int i,
java.lang.Object value)
Strategy method allowing derived classes to handle types differently such as for CLOBs etc. |
protected void |
setParameters(java.util.List params,
java.sql.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 |
protected java.util.logging.Logger log
Constructor Detail |
public Sql(javax.sql.DataSource dataSource)
dataSource
- public Sql(java.sql.Connection connection)
close()
method.
connection
- public Sql(Sql parent)
Method Detail |
public static Sql newInstance(java.lang.String url) throws java.sql.SQLException
url
-
java.sql.SQLException
public static Sql newInstance(java.lang.String url, java.util.Properties properties) throws java.sql.SQLException
url
-
java.sql.SQLException
public static Sql newInstance(java.lang.String url, java.util.Properties properties, java.lang.String driverClassName) throws java.sql.SQLException, java.lang.ClassNotFoundException
url
-
java.sql.SQLException
java.lang.ClassNotFoundException
public static Sql newInstance(java.lang.String url, java.lang.String user, java.lang.String password) throws java.sql.SQLException
url
-
java.sql.SQLException
public static Sql newInstance(java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String driverClassName) throws java.sql.SQLException, java.lang.ClassNotFoundException
url
-
java.sql.SQLException
java.lang.ClassNotFoundException
public static Sql newInstance(java.lang.String url, java.lang.String driverClassName) throws java.sql.SQLException, java.lang.ClassNotFoundException
url
- driverClassName
- the class name of the driver
java.sql.SQLException
java.lang.ClassNotFoundException
public static void loadDriver(java.lang.String driverClassName) throws java.lang.ClassNotFoundException
driverClassName
-
java.lang.ClassNotFoundException
public DataSet dataSet(java.lang.String table)
public DataSet dataSet(java.lang.Class type)
public void query(java.lang.String sql, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void query(java.lang.String sql, java.util.List params, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void query(GString gstring, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void queryEach(java.lang.String sql, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void eachRow(java.lang.String sql, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void queryEach(java.lang.String sql, java.util.List params, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void eachRow(java.lang.String sql, java.util.List params, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void eachRow(GString gstring, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public void queryEach(GString gstring, Closure closure) throws java.sql.SQLException
java.sql.SQLException
public boolean execute(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
java.sql.SQLException
public boolean execute(java.lang.String sql, java.util.List params) throws java.sql.SQLException
java.sql.SQLException
public int executeUpdate(java.lang.String sql, java.util.List params) throws java.sql.SQLException
java.sql.SQLException
public boolean execute(GString gstring) throws java.sql.SQLException
java.sql.SQLException
public int executeUpdate(GString gstring) throws java.sql.SQLException
java.sql.SQLException
public int call(java.lang.String sql) throws java.lang.Exception
java.lang.Exception
public int call(java.lang.String sql, java.util.List params) throws java.lang.Exception
java.lang.Exception
public int call(GString gstring) throws java.lang.Exception
java.lang.Exception
public void close() throws java.sql.SQLException
java.sql.SQLException
public javax.sql.DataSource getDataSource()
protected java.lang.String asSql(GString gstring)
protected java.lang.String nullify(java.lang.String sql)
sql
-
protected int findWhereKeyword(java.lang.String sql)
sql
-
protected java.util.List getParameters(GString gstring)
protected void setParameters(java.util.List params, java.sql.PreparedStatement statement) throws java.sql.SQLException
java.sql.SQLException
protected void setObject(java.sql.PreparedStatement statement, int i, java.lang.Object value) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.Connection createConnection() throws java.sql.SQLException
java.sql.SQLException
protected void closeResources(java.sql.Connection connection, java.sql.Statement statement, java.sql.ResultSet results)
protected void closeResources(java.sql.Connection connection, java.sql.Statement statement)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |