All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.datahandlers.Parameters

java.lang.Object
   |
   +----org.xmlmiddleware.xmldbms.datahandlers.Parameters

public class Parameters
extends Object
Sets parameters in an SQL statement.

The methods in this class assume that the arrays of parameter values and Columns are in the same order as the parameters in the SQL statement.

Methods that require parameter values to be of the default object type for the column type use the following default object types:

 CHAR, VARCHAR, LONGVARCHAR:        String
DATE, TIME, TIMESTAMP: java.sql.Date
BIGINT: Long
INTEGER: Integer
SMALLINT: Short
TINYINT: Byte
DECIMAL, NUMERIC: BigDecimal
DOUBLE, FLOAT: Double
REAL: Float
BINARY, VARBINARY, LONGVARBINARY: org.xmlmiddleware.conversions.ByteArray
BIT: Boolean

Version:
2.0
Author:
Ronald Bourret

Constructor Index

 o Parameters()

Method Index

 o convertAndSetParameter(PreparedStatement, int, Column, Object)
Set a single parameter, converting the object type first if necessary.
 o convertAndSetParameters(PreparedStatement, int, Column[], Object[])
Set parameters from an array of values, converting the object type first if necessary.
 o setParameter(PreparedStatement, int, Column, Object)
Set a single parameter.
 o setParameters(PreparedStatement, int, Column[], Object[])
Set parameters from an array of values.

Constructors

 o Parameters
 public Parameters()

Methods

 o setParameters
 public static void setParameters(PreparedStatement p,
                                  int offset,
                                  Column columns[],
                                  Object values[]) throws SQLException
Set parameters from an array of values.

For best performance, parameter values should be of the default object type for the parameter type.

Parameters:
p - Prepared SQL statement
offset - Offset into the list of parameters in the prepared statement. To start with the first parameter, use an offset of 0.
columns - An array of Column objects corresponding to the parameters.
values - Parameter values.
Throws: SQLException
A database error occurred while setting the parameter.
 o setParameter
 public static void setParameter(PreparedStatement p,
                                 int number,
                                 Column column,
                                 Object value) throws SQLException
Set a single parameter.

For best performance, parameter values should be of the default object type for the parameter type.

Parameters:
p - Prepared SQL statement
number - The parameter number (1-based)
column - The column corresponding to the parameter
value - The parameter value
Throws: SQLException
A database error occurred while setting the parameter.
 o convertAndSetParameters
 public static void convertAndSetParameters(PreparedStatement p,
                                            int offset,
                                            Column columns[],
                                            Object values[]) throws SQLException
Set parameters from an array of values, converting the object type first if necessary.

This method checks the object type of the parameter values and performs any necessary conversions before setting the parameter value. If the parameter values are all known to be of the default type, use setParameters instead, since it is faster.

Parameters:
p - Prepared SQL statement
offset - Offset into the list of parameters in the prepared statement. To start with the first parameter, use an offset of 0.
columns - An array of Column objects corresponding to the parameters.
values - Parameter values.
Throws: SQLException
A database error occurred while setting the parameter.
 o convertAndSetParameter
 public static void convertAndSetParameter(PreparedStatement p,
                                           int number,
                                           Column column,
                                           Object value) throws SQLException
Set a single parameter, converting the object type first if necessary.

This method checks the object type of the parameter value and performs any necessary conversion before setting the parameter value. If the parameter value is known to be of the default type, use setParameters instead, since it is faster.

Parameters:
p - Prepared SQL statement
number - The parameter number (1-based)
column - A Column object describing the parameter.
value - The parameter value.
Throws: SQLException
A database error occurred while setting the parameter.

All Packages  Class Hierarchy  This Package  Previous  Next  Index