org.qi4j.library.sql.datasource
Class Databases

java.lang.Object
  extended by org.qi4j.library.sql.datasource.Databases

public class Databases
extends Object

Utility methods for performing SQL calls. Wraps a given DataSource.


Nested Class Summary
static interface Databases.ResultSetVisitor
          Visitor for the ResultSet.
static interface Databases.StatementVisitor
          Visitor for PreparedStatements.
 
Constructor Summary
Databases(DataSource source)
          Create a new Databases wrapper for a given DataSource
 
Method Summary
 Input<ResultSet,SQLException> query(String sql)
          Perform SQL query and provide results as an Input.
 void query(String sql, Databases.ResultSetVisitor visitor)
          Perform SQL query and let visitor handle results.
 Input<ResultSet,SQLException> query(String sql, Databases.StatementVisitor visitor)
          Perform SQL query and provide results as an Input.
 void query(String sql, Databases.StatementVisitor statement, Databases.ResultSetVisitor resultsetVisitor)
          Perform SQL query and let visitor handle results.
 int update(String sql)
          Perform SQL update statement
 int update(String sql, Databases.StatementVisitor visitor)
          Perform SQL update statement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Databases

public Databases(DataSource source)
Create a new Databases wrapper for a given DataSource

Parameters:
source -
Method Detail

update

public int update(String sql)
           throws SQLException
Perform SQL update statement

Parameters:
sql -
Returns:
Throws:
SQLException

update

public int update(String sql,
                  Databases.StatementVisitor visitor)
           throws SQLException
Perform SQL update statement. If the SQL string contains ? placeholders, use the StatementVisitor to update the PreparedStatement with actual values.

Parameters:
sql -
visitor -
Returns:
Throws:
SQLException

query

public void query(String sql,
                  Databases.ResultSetVisitor visitor)
           throws SQLException
Perform SQL query and let visitor handle results.

Parameters:
sql -
visitor -
Throws:
SQLException

query

public void query(String sql,
                  Databases.StatementVisitor statement,
                  Databases.ResultSetVisitor resultsetVisitor)
           throws SQLException
Perform SQL query and let visitor handle results. If the SQL string contains ? placeholders, use the StatementVisitor to update the PreparedStatement with actual values.

Parameters:
sql -
statement -
resultsetVisitor -
Throws:
SQLException

query

public Input<ResultSet,SQLException> query(String sql)
Perform SQL query and provide results as an Input. This makes it possible to combine SQL data with the I/O API.

Parameters:
sql -
Returns:

query

public Input<ResultSet,SQLException> query(String sql,
                                           Databases.StatementVisitor visitor)
Perform SQL query and provide results as an Input. This makes it possible to combine SQL data with the I/O API. If the SQL string contains ? placeholders, use the StatementVisitor to update the PreparedStatement with actual values.

Parameters:
sql -
Returns: