com.interface21.jdbc.core
Class PreparedStatementCreatorFactory

java.lang.Object
  |
  +--com.interface21.jdbc.core.PreparedStatementCreatorFactory

public class PreparedStatementCreatorFactory
extends java.lang.Object

Helper class that can efficiently create multiple PreparedStatementCreator objects with different parameters based on a SQL statement and a single set of parameter declarations.

Version:
$Id: PreparedStatementCreatorFactory.java,v 1.2 2003/03/08 20:44:12 trisberg Exp $
Author:
Rod Johnson

Constructor Summary
PreparedStatementCreatorFactory(java.lang.String sql)
          Create a new factory.
PreparedStatementCreatorFactory(java.lang.String sql, int[] types)
          Create a new factory with sql and parameters with the given JDBC types
PreparedStatementCreatorFactory(java.lang.String sql, java.util.List declaredParameters)
          Create a new factory with sql and the given parameters
 
Method Summary
 void addParameter(SqlParameter p)
          Add a new declared parameter Order of parameter addition is significant
 PreparedStatementCreator newPreparedStatementCreator(java.util.List params)
          Return a new PreparedStatementCreator instance given this parameters.
 PreparedStatementCreator newPreparedStatementCreator(java.lang.Object[] params)
          Return a new PreparedStatementCreator given these parameters
static PreparedStatementCreator newPreparedStatementCreator(java.lang.String sql)
          Convenient method to return a PreparedStatementCreator that has no arguments
static PreparedStatementCreator newPreparedStatementCreator(java.lang.String sql, int[] types, java.lang.Object[] params)
          Convenient method to declare variables and parameters in a single operation.
static java.util.List sqlTypesToAnonymousParameterList(int[] types)
          Convert a list of JDBC types, as defined in the java.sql.Types class, to a List of SqlParameter objects as used in this package
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreparedStatementCreatorFactory

public PreparedStatementCreatorFactory(java.lang.String sql)
Create a new factory. Will need to add parameters via the addParameter() method or have no parameters

PreparedStatementCreatorFactory

public PreparedStatementCreatorFactory(java.lang.String sql,
                                       int[] types)
Create a new factory with sql and parameters with the given JDBC types
Parameters:
sql - SQL to execute
types - int array of JDBC types

PreparedStatementCreatorFactory

public PreparedStatementCreatorFactory(java.lang.String sql,
                                       java.util.List declaredParameters)
Create a new factory with sql and the given parameters
Parameters:
sql - SQL
declaredParameters - list of SqlParameter objects
Method Detail

newPreparedStatementCreator

public static PreparedStatementCreator newPreparedStatementCreator(java.lang.String sql)
Convenient method to return a PreparedStatementCreator that has no arguments

newPreparedStatementCreator

public static PreparedStatementCreator newPreparedStatementCreator(java.lang.String sql,
                                                                   int[] types,
                                                                   java.lang.Object[] params)
Convenient method to declare variables and parameters in a single operation. If issuing multiple statements with the same parameters, construct an instance of PreparedStatementCreatorFactory to hold the parameters instead.

sqlTypesToAnonymousParameterList

public static java.util.List sqlTypesToAnonymousParameterList(int[] types)
Convert a list of JDBC types, as defined in the java.sql.Types class, to a List of SqlParameter objects as used in this package

addParameter

public void addParameter(SqlParameter p)
Add a new declared parameter Order of parameter addition is significant

newPreparedStatementCreator

public PreparedStatementCreator newPreparedStatementCreator(java.lang.Object[] params)
Return a new PreparedStatementCreator given these parameters
Parameters:
params - parameter array. May be null.

newPreparedStatementCreator

public PreparedStatementCreator newPreparedStatementCreator(java.util.List params)
Return a new PreparedStatementCreator instance given this parameters.
Parameters:
params - List of parameters. May be null.


Rod Johnson and Spring contributors 2001-2003.