biz.hammurapi.sql
Class SQLProcessor

java.lang.Object
  extended by biz.hammurapi.sql.SQLProcessor

public class SQLProcessor
extends java.lang.Object

This class contains methods to process SQL statements in more convenient way comparing to standard JDBC.

Version:
$Revision: 1.14 $
Author:
Pavel Vlasov

Constructor Summary
SQLProcessor(java.sql.Connection connection, Context nameMap)
          If SQLProcessor created with this constructor then is doesn't close the connection after processing.
SQLProcessor(javax.sql.DataSource dataSource, Context nameMap)
          If SQLProcessor constructed with this constructor then it obtains connection from the datasource, processes request and closes connection.
 
Method Summary
 void executeScript(java.io.Reader reader)
          Excecutes script with ; as statement separator
 void executeScript(java.io.Reader reader, char statementSeparator)
          Executes series of SQL statement read from reader and separated by statementSeparator
 void executeScript(java.io.Reader reader, char statementSeparator, ExceptionSink exceptionSink)
           
 void executeTransaction(Transaction transaction)
           
static java.lang.String findProjectSingleMethodName(java.lang.String className)
          Finds projectSingleXXX method for a particular type.
 java.sql.Connection getConnection()
          Returns connection if you need it for JDBC calls outside of the SQLProcessor
protected  javax.sql.DataSource getDataSource()
           
 Context getNameMap()
           
 TimeIntervalCategory getTimeIntervalCategory()
           
 void inject(StatementFragment fragment, java.util.Map columnMap, java.lang.Object target)
           
 void inject(java.lang.String sql, Parameterizer parameterizer, java.util.Map columnMap, java.lang.Object target)
          Executes query and injects values from the first row to target object.
static void main(java.lang.String[] args)
           
 int nextPK(java.sql.Connection con, java.lang.String primaryKeysTable, java.lang.String keyName)
           
 int nextPK(java.lang.String primaryKeysTable, java.lang.String keyName)
          Generates primary key.
 java.lang.String parse(java.lang.String str)
          Replaces ${} with property value.
 void processResourceSelect(java.lang.String resourceName, Parameterizer parameterizer, RowProcessor rowProcessor)
          Processes SELECT statement read from resource file.
 int processResourceUpdate(java.lang.String resourceName, Parameterizer parameterizer)
          Processes SELECT statement read from resource file.
 void processSelect(StatementFragment fragment, RowProcessor rowProcessor)
           
 void processSelect(java.lang.String sql, Parameterizer parameterizer, RowProcessor rowProcessor)
          Processes SQL SELECT statement in the following way: Obtains connection If parameterizer==null creates Statement, creates PreparedStatement otherwise Invokes parameterizer.parameterize() if parameterizer is not null Iterates through result set and invokes rowProcessor.process() on each row If there was no rows and rowProcess is instance of RowProcessorEx then rowProcessor.onEmptyResultSet() is invoked ResultSet, Statement and connection are properly released
 int processUpdate(StatementFragment fragment)
           
 int processUpdate(java.lang.String sql, Parameterizer parameterizer)
          Processes SQL INSERT, UPDATE or DELETE statement in the following way: Obtains connection If parameterizer==null creates Statement, creates PreparedStatement otherwise Invokes parameterizer.parameterize() if parameterizer is not null Executes update ResultSet, Statement and connection are properly released
 java.util.Collection project(StatementFragment fragment)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface, java.util.Collection receiver)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface, int pageNum, int pageSize)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface, java.lang.Object delegate)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface, java.lang.Object delegate, java.util.Collection receiver)
           
 java.util.Collection project(StatementFragment fragment, java.lang.Class theInterface, java.lang.Object delegate, int pageNum, int pageSize)
           
 java.util.Collection project(StatementFragment fragment, Projector projector)
           
 java.util.Collection project(StatementFragment fragment, Projector projector, java.util.Collection receiver)
           
 java.util.Collection project(StatementFragment fragment, Projector projector, java.util.Collection receiver, int pageSize, int pageNum)
           
 java.util.Collection project(StatementFragment fragment, Projector projector, int pageNum, int pageSize)
           
 java.util.Collection project(java.lang.String sql)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, java.util.Collection receiver)
          Executes SQL statement and puts results to receiver
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, int pageNum, int pageSize)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, java.lang.Object delegate)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, java.lang.Object delegate, java.util.Collection receiver)
          Executes SQL statement and puts results to receiver
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, java.lang.Object delegate, int pageNum, int pageSize)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, Projector projector)
          Executes SQL statement and returns collection backed by the database.
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, Projector projector, java.util.Collection receiver)
          Executes SQL statement and puts results to receiver
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, Projector projector, java.util.Collection receiver, int pageSize, int pageNum)
          Executes SQL statement and puts results to receiver
 java.util.Collection project(java.lang.String sql, Parameterizer parameterizer, Projector projector, int pageNum, int pageSize)
          Executes SQL statement and returns collection backed by the database.
 boolean projectSingleBoolean(StatementFragment fragment)
           
 boolean projectSingleBoolean(java.lang.String sql, Parameterizer parameterizer)
           
 byte projectSingleByte(StatementFragment fragment)
           
 byte projectSingleByte(java.lang.String sql, Parameterizer parameterizer)
           
 byte[] projectSingleBytes(StatementFragment fragment)
           
 byte[] projectSingleBytes(java.lang.String sql, Parameterizer parameterizer)
           
 char projectSingleChar(StatementFragment fragment)
           
 char projectSingleChar(java.lang.String sql, Parameterizer parameterizer)
           
 double projectSingleDouble(StatementFragment fragment)
           
 double projectSingleDouble(java.lang.String sql, Parameterizer parameterizer)
           
 float projectSingleFloat(StatementFragment fragment)
           
 float projectSingleFloat(java.lang.String sql, Parameterizer parameterizer)
           
 int projectSingleInt(StatementFragment fragment)
           
 int projectSingleInt(java.lang.String sql, Parameterizer parameterizer)
           
 long projectSingleLong(StatementFragment fragment)
           
 long projectSingleLong(java.lang.String sql, Parameterizer parameterizer)
           
 java.lang.Object projectSingleObject(StatementFragment fragment)
           
 java.lang.Object projectSingleObject(StatementFragment fragment, java.lang.Class theInterface)
           
 java.lang.Object projectSingleObject(StatementFragment fragment, java.lang.Class theInterface, java.lang.Object delegate)
           
 java.lang.Object projectSingleObject(StatementFragment fragment, Projector projector)
           
 java.lang.Object projectSingleObject(java.lang.String sql, Parameterizer parameterizer)
           
 java.lang.Object projectSingleObject(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface)
           
 java.lang.Object projectSingleObject(java.lang.String sql, Parameterizer parameterizer, java.lang.Class theInterface, java.lang.Object delegate)
           
 java.lang.Object projectSingleObject(java.lang.String sql, Parameterizer parameterizer, Projector projector)
           
 short projectSingleShort(StatementFragment fragment)
           
 short projectSingleShort(java.lang.String sql, Parameterizer parameterizer)
           
 java.lang.String projectSingleString(StatementFragment fragment)
           
 java.lang.String projectSingleString(java.lang.String sql, Parameterizer parameterizer)
           
 void releaseConnection(java.sql.Connection connection)
          Closes connection if it was provided by DataSource.
 void setTimeIntervalCategory(TimeIntervalCategory timeIntervalCategory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLProcessor

public SQLProcessor(javax.sql.DataSource dataSource,
                    Context nameMap)
If SQLProcessor constructed with this constructor then it obtains connection from the datasource, processes request and closes connection.

Parameters:
dataSource - DataSource
nameMap - NameMap allows to write parameterized SQL statements like "SELECT ${AMOUNT} FROM ${ACCOUNT} WHERE ${ANUM}=? AND CLOSED=1" nameMap shall contain mapping from AMOUNT, ACCOUNT and ANUM to actual database field names. If nameMap doesn't contain mapping for some properties then property names will be used as property values. See PropertyParser. One property value can contain a reference to another property. If nameMap is null then no property parsing will happen.

SQLProcessor

public SQLProcessor(java.sql.Connection connection,
                    Context nameMap)
If SQLProcessor created with this constructor then is doesn't close the connection after processing.

Parameters:
connection -
nameMap - See biz.hammurapi.sql.SQLProcessor#SQLProcessor(DataSource, Properties)
Method Detail

parse

public java.lang.String parse(java.lang.String str)
Replaces ${} with property value. See PropertyParser

Parameters:
str -
Returns:
parsed string

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns connection if you need it for JDBC calls outside of the SQLProcessor

Returns:
Connection
Throws:
java.sql.SQLException

releaseConnection

public void releaseConnection(java.sql.Connection connection)
                       throws java.sql.SQLException
Closes connection if it was provided by DataSource. Does nothing otherwise.

Parameters:
connection - Connection to release.
Throws:
java.sql.SQLException

processSelect

public void processSelect(StatementFragment fragment,
                          RowProcessor rowProcessor)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

processSelect

public void processSelect(java.lang.String sql,
                          Parameterizer parameterizer,
                          RowProcessor rowProcessor)
                   throws java.sql.SQLException
Processes SQL SELECT statement in the following way:

Parameters:
sql - SQL statment to execute
parameterizer - Parameterizer
rowProcessor - RowProcessor
Throws:
java.sql.SQLException

processUpdate

public int processUpdate(StatementFragment fragment)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

processUpdate

public int processUpdate(java.lang.String sql,
                         Parameterizer parameterizer)
                  throws java.sql.SQLException
Processes SQL INSERT, UPDATE or DELETE statement in the following way:

Parameters:
sql - SQL statment to execute
parameterizer - Parameterizer
Returns:
Number of updates. See Statement.executeUpdate(java.lang.String)
Throws:
java.sql.SQLException

processResourceSelect

public void processResourceSelect(java.lang.String resourceName,
                                  Parameterizer parameterizer,
                                  RowProcessor rowProcessor)
                           throws java.sql.SQLException,
                                  java.io.IOException
Processes SELECT statement read from resource file. Suitable for huge SQL statements or SQL statements maintained by other developers.

Parameters:
resourceName -
parameterizer -
rowProcessor -
Throws:
java.sql.SQLException
java.io.IOException

processResourceUpdate

public int processResourceUpdate(java.lang.String resourceName,
                                 Parameterizer parameterizer)
                          throws java.sql.SQLException,
                                 java.io.IOException
Processes SELECT statement read from resource file. Suitable for huge SQL statements or SQL statements maintained by other developers.

Parameters:
resourceName -
parameterizer -
Returns:
Number of updates. See Statement.executeUpdate(java.lang.String)
Throws:
java.sql.SQLException
java.io.IOException

executeScript

public void executeScript(java.io.Reader reader)
                   throws java.io.IOException,
                          java.sql.SQLException
Excecutes script with ; as statement separator

Parameters:
reader - Script source
Throws:
java.io.IOException
java.sql.SQLException
See Also:
executeScript(Reader, char)

executeScript

public void executeScript(java.io.Reader reader,
                          char statementSeparator)
                   throws java.io.IOException,
                          java.sql.SQLException
Executes series of SQL statement read from reader and separated by statementSeparator

Parameters:
reader - Script source
statementSeparator - Statement separator
Throws:
java.io.IOException
java.sql.SQLException

executeScript

public void executeScript(java.io.Reader reader,
                          char statementSeparator,
                          ExceptionSink exceptionSink)
                   throws java.io.IOException,
                          java.sql.SQLException
Parameters:
reader - Script source
statementSeparator - Statement separator
exceptionSink - Exception sink. Consumes exceptions thrown by individual statements. If sink is null then exception is rethrown and script execution terminates.
Throws:
java.io.IOException
java.sql.SQLException

project

public java.util.Collection project(StatementFragment fragment,
                                    Projector projector)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    Projector projector)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
projector - Projector which instantiates objects. It is null then projector which projects row to collection will be used.
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer)
Executes SQL statement and returns collection backed by the database. Rows are projected to collection of field values.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
projector - Projector which instantiates objects. It is null then projector which projects row to collection will be used.
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor and parameterizer. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(java.lang.String sql)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Iterface to implement
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Interface to implement
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    Projector projector,
                                    int pageNum,
                                    int pageSize)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    Projector projector,
                                    int pageNum,
                                    int pageSize)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
projector - Projector which instantiates objects. If it is null then projector which projects row to collection will be used
pageSize - Maximum number of records to return
pageNum - Number of page. Starts with 1.
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface,
                                    int pageNum,
                                    int pageSize)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface,
                                    int pageNum,
                                    int pageSize)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Interface to implement
pageSize - Maximum number of records to return
pageNum - Number of page. Starts with 1.
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate,
                                    int pageNum,
                                    int pageSize)

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate,
                                    int pageNum,
                                    int pageSize)
Executes SQL statement and returns collection backed by the database.

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Interface to implement
delegate - Object to delegate invocations which didn't match field getters/setters
pageSize - Maximum number of records to return
pageNum - Number of page. Starts with 1.
Returns:
Collection backed by the database. The collection doesn't hold any SQL resources open, neither it keeps any refernces to created objects. It keeps only references to the SQLProcessor, parameterizer and projector. Thus any call to one of collection methods retursn 'fresh' results from the database. Iterators created by this collection open ResultSet and close it when Iterator.hasNext() returns false.

project

public java.util.Collection project(StatementFragment fragment,
                                    Projector projector,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    Projector projector,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Executes SQL statement and puts results to receiver

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
projector - Projector which instantiates objects. If it is null then projector which projects row to collection will be used
receiver - Collection to put results to
Returns:
receiver with added objects. Convenient for calls like Iterator it=processor.project(..., new LinkedList());
Throws:
java.sql.SQLException

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Executes SQL statement and puts results to receiver

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Interface to implement
receiver - Collection to put results to
Returns:
receiver with added objects. Convenient for calls like Iterator it=processor.project(..., new LinkedList());
Throws:
java.sql.SQLException

project

public java.util.Collection project(StatementFragment fragment,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    java.lang.Class theInterface,
                                    java.lang.Object delegate,
                                    java.util.Collection receiver)
                             throws java.sql.SQLException
Executes SQL statement and puts results to receiver

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
theInterface - Interface to implement
delegate - Object to delegate invocations which didn't match field getters/setters.
receiver - Collection to put results to
Returns:
receiver with added objects. Convenient for calls like Iterator it=processor.project(..., new LinkedList());
Throws:
java.sql.SQLException

project

public java.util.Collection project(StatementFragment fragment,
                                    Projector projector,
                                    java.util.Collection receiver,
                                    int pageSize,
                                    int pageNum)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

project

public java.util.Collection project(java.lang.String sql,
                                    Parameterizer parameterizer,
                                    Projector projector,
                                    java.util.Collection receiver,
                                    int pageSize,
                                    int pageNum)
                             throws java.sql.SQLException
Executes SQL statement and puts results to receiver

Parameters:
sql - Select statement to execute
parameterizer - Parameterizer
projector - Projector which instantiates objects. If it is null then projector which projects row to collection will be used.
receiver - Collection to put results to
pageSize - Maximum number of records to return
pageNum - Number of page. Starts with 1.
Returns:
receiver with added objects. Convenient for calls like Iterator it=processor.project(..., new LinkedList());
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(StatementFragment fragment,
                                            Projector projector)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(java.lang.String sql,
                                            Parameterizer parameterizer,
                                            Projector projector)
                                     throws java.sql.SQLException
Parameters:
string -
parameterizer -
projector - Projector. If it is null then projector which projects row to collection will be used.
Returns:
Throws:
java.sql.SQLException

inject

public void inject(StatementFragment fragment,
                   java.util.Map columnMap,
                   java.lang.Object target)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

inject

public void inject(java.lang.String sql,
                   Parameterizer parameterizer,
                   java.util.Map columnMap,
                   java.lang.Object target)
            throws java.sql.SQLException
Executes query and injects values from the first row to target object.

Parameters:
string -
parameterizer -
target - Object to inject values to
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(StatementFragment fragment,
                                            java.lang.Class theInterface)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(java.lang.String sql,
                                            Parameterizer parameterizer,
                                            java.lang.Class theInterface)
                                     throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
Object representing first row
Throws:
java.sql.SQLException

projectSingleBoolean

public boolean projectSingleBoolean(StatementFragment fragment)
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleBoolean

public boolean projectSingleBoolean(java.lang.String sql,
                                    Parameterizer parameterizer)
                             throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
boolean value of the first column of the first row or 'false' if there are no rows.
Throws:
java.sql.SQLException

projectSingleByte

public byte projectSingleByte(StatementFragment fragment)
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleByte

public byte projectSingleByte(java.lang.String sql,
                              Parameterizer parameterizer)
                       throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
byte value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleBytes

public byte[] projectSingleBytes(StatementFragment fragment)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleBytes

public byte[] projectSingleBytes(java.lang.String sql,
                                 Parameterizer parameterizer)
                          throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
byte[] value of the first column of the first row or null if there are no rows.
Throws:
java.sql.SQLException

projectSingleInt

public int projectSingleInt(StatementFragment fragment)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleInt

public int projectSingleInt(java.lang.String sql,
                            Parameterizer parameterizer)
                     throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
int value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleShort

public short projectSingleShort(StatementFragment fragment)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleShort

public short projectSingleShort(java.lang.String sql,
                                Parameterizer parameterizer)
                         throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
short value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleDouble

public double projectSingleDouble(StatementFragment fragment)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleDouble

public double projectSingleDouble(java.lang.String sql,
                                  Parameterizer parameterizer)
                           throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
double value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleFloat

public float projectSingleFloat(StatementFragment fragment)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleFloat

public float projectSingleFloat(java.lang.String sql,
                                Parameterizer parameterizer)
                         throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
float value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleLong

public long projectSingleLong(StatementFragment fragment)
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleLong

public long projectSingleLong(java.lang.String sql,
                              Parameterizer parameterizer)
                       throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
long value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleString

public java.lang.String projectSingleString(StatementFragment fragment)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleString

public java.lang.String projectSingleString(java.lang.String sql,
                                            Parameterizer parameterizer)
                                     throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
String value of the first column of the first row or null if there are no rows.
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(StatementFragment fragment)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(java.lang.String sql,
                                            Parameterizer parameterizer)
                                     throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
object value of the first column of the first row or null if there are no rows.
Throws:
java.sql.SQLException

findProjectSingleMethodName

public static java.lang.String findProjectSingleMethodName(java.lang.String className)
Finds projectSingleXXX method for a particular type.

Parameters:
className -
Returns:

projectSingleChar

public char projectSingleChar(StatementFragment fragment)
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleChar

public char projectSingleChar(java.lang.String sql,
                              Parameterizer parameterizer)
                       throws java.sql.SQLException
Parameters:
sql -
parameterizer -
Returns:
char value of the first column of the first row or 0 if there are no rows.
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(StatementFragment fragment,
                                            java.lang.Class theInterface,
                                            java.lang.Object delegate)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

projectSingleObject

public java.lang.Object projectSingleObject(java.lang.String sql,
                                            Parameterizer parameterizer,
                                            java.lang.Class theInterface,
                                            java.lang.Object delegate)
                                     throws java.sql.SQLException
Parameters:
string -
parameterizer -
Returns:
Throws:
java.sql.SQLException

nextPK

public int nextPK(java.lang.String primaryKeysTable,
                  java.lang.String keyName)
           throws java.sql.SQLException
Generates primary key.

Parameters:
primaryKeysTable - Table holding primary keys counters. DDL:
CREATE TABLE table name (
       KEY_NAME VARCHAR(50) NOT NULL
     , KEY_VALUE INTEGER DEFAULT '0' NOT NULL
     , PRIMARY KEY (KEY_NAME)
);
keyName - Key name
Returns:
Throws:
java.sql.SQLException

nextPK

public int nextPK(java.sql.Connection con,
                  java.lang.String primaryKeysTable,
                  java.lang.String keyName)
           throws java.sql.SQLException
Parameters:
con -
primaryKeysTable -
keyName -
Returns:
Throws:
java.sql.SQLException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getTimeIntervalCategory

public TimeIntervalCategory getTimeIntervalCategory()

setTimeIntervalCategory

public void setTimeIntervalCategory(TimeIntervalCategory timeIntervalCategory)

getNameMap

public Context getNameMap()

executeTransaction

public void executeTransaction(Transaction transaction)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

getDataSource

protected javax.sql.DataSource getDataSource()


Copyright © 2003 Hammurapi Group. All Rights Reserved.