net.walend.jdbc
Class SQLStatementString

java.lang.Object
  |
  +--net.walend.jdbc.SQLStatementString

public class SQLStatementString
extends java.lang.Object

This class exists to provide '?' substitutions to Statements that are not PreparedStatements.

Since:
Author:
David Walend

Field Summary
private  java.lang.String[] parameters
           
private  java.lang.String sqlString
           
 
Constructor Summary
SQLStatementString(java.lang.String sqlString)
           
 
Method Summary
 void clearParameters()
          Clears the current parameter values immediately.
private  int countParameters()
           
private  java.lang.String escapeSingleQuotes(java.lang.String string)
           
private  java.lang.String getParameter(int i)
           
 java.lang.String getSQLString()
           
private  boolean parametersFilled()
           
 void setBoolean(int parameterIndex, boolean x)
          Sets the designated parameter to a Java boolean value.
 void setByte(int parameterIndex, byte x)
          Sets the designated parameter to a Java byte value.
 void setBytes(int parameterIndex, byte[] x)
          Sets the designated parameter to a Java array of bytes.
 void setDate(int parameterIndex, java.sql.Date x)
          Sets the designated parameter to a value.
 void setDate(int parameterIndex, java.util.Date x)
           
 void setDouble(int parameterIndex, double x)
          Sets the designated parameter to a Java double value.
 void setFloat(int parameterIndex, float x)
          Sets the designated parameter to a Java float value.
 void setInt(int parameterIndex, int x)
          Sets the designated parameter to a Java int value.
 void setLong(int parameterIndex, long x)
          Sets the designated parameter to a Java long value.
 void setNull(int parameterIndex, int sqlType)
          Sets the designated parameter to SQL NULL.
 void setObject(int parameterIndex, java.lang.Object x)
           
private  void setParameter(int i, java.lang.String string)
          This method changes the parameters from 1-based (jdbc) to 0-based (everything else).
 void setShort(int parameterIndex, short x)
          Sets the designated parameter to a Java short value.
 void setString(int parameterIndex, java.lang.String x)
          Sets the designated parameter to a Java String value.
 void setStringNoQuotes(int parameterIndex, java.lang.String x)
          Sets the designated parameter to a Java String value without quotes.
 void setTime(int parameterIndex, java.sql.Time x)
          Sets the designated parameter to a java.sql.Time value.
 void setTimestamp(int parameterIndex, java.sql.Timestamp x)
          Sets the designated parameter to a java.sql.Timestamp value.
private  int[] whichParametersMissing()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sqlString

private java.lang.String sqlString

parameters

private java.lang.String[] parameters
Constructor Detail

SQLStatementString

public SQLStatementString(java.lang.String sqlString)
Method Detail

parametersFilled

private boolean parametersFilled()

whichParametersMissing

private int[] whichParametersMissing()

getParameter

private java.lang.String getParameter(int i)

getSQLString

public java.lang.String getSQLString()
                              throws java.sql.SQLException

countParameters

private int countParameters()

setParameter

private void setParameter(int i,
                          java.lang.String string)
This method changes the parameters from 1-based (jdbc) to 0-based (everything else).


setNull

public void setNull(int parameterIndex,
                    int sqlType)
             throws java.sql.SQLException
Sets the designated parameter to SQL NULL.

Note: You must specify the parameter's SQL type.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
sqlType - the SQL type code defined in java.sql.Types
Throws:
java.sql.SQLException - if a database access error occurs

setBoolean

public void setBoolean(int parameterIndex,
                       boolean x)
                throws java.sql.SQLException
Sets the designated parameter to a Java boolean value. The driver converts this to an SQL BIT value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setByte

public void setByte(int parameterIndex,
                    byte x)
             throws java.sql.SQLException
Sets the designated parameter to a Java byte value. The driver converts this to an SQL TINYINT value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setShort

public void setShort(int parameterIndex,
                     short x)
              throws java.sql.SQLException
Sets the designated parameter to a Java short value. The driver converts this to an SQL SMALLINT value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setInt

public void setInt(int parameterIndex,
                   int x)
            throws java.sql.SQLException
Sets the designated parameter to a Java int value. The driver converts this to an SQL INTEGER value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setLong

public void setLong(int parameterIndex,
                    long x)
             throws java.sql.SQLException
Sets the designated parameter to a Java long value. The driver converts this to an SQL BIGINT value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setFloat

public void setFloat(int parameterIndex,
                     float x)
              throws java.sql.SQLException
Sets the designated parameter to a Java float value. The driver converts this to an SQL FLOAT value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setDouble

public void setDouble(int parameterIndex,
                      double x)
               throws java.sql.SQLException
Sets the designated parameter to a Java double value. The driver converts this to an SQL DOUBLE value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

escapeSingleQuotes

private java.lang.String escapeSingleQuotes(java.lang.String string)

setString

public void setString(int parameterIndex,
                      java.lang.String x)
               throws java.sql.SQLException
Sets the designated parameter to a Java String value. The driver converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setStringNoQuotes

public void setStringNoQuotes(int parameterIndex,
                              java.lang.String x)
                       throws java.sql.SQLException
Sets the designated parameter to a Java String value without quotes.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBytes

public void setBytes(int parameterIndex,
                     byte[] x)
              throws java.sql.SQLException
Sets the designated parameter to a Java array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setDate

public void setDate(int parameterIndex,
                    java.sql.Date x)
             throws java.sql.SQLException
Sets the designated parameter to a value. The driver converts this to an SQL DATE value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setDate

public void setDate(int parameterIndex,
                    java.util.Date x)
             throws java.sql.SQLException

setTime

public void setTime(int parameterIndex,
                    java.sql.Time x)
             throws java.sql.SQLException
Sets the designated parameter to a java.sql.Time value. The driver converts this to an SQL TIME value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setTimestamp

public void setTimestamp(int parameterIndex,
                         java.sql.Timestamp x)
                  throws java.sql.SQLException
Sets the designated parameter to a java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setObject

public void setObject(int parameterIndex,
                      java.lang.Object x)
               throws java.sql.SQLException

clearParameters

public void clearParameters()
                     throws java.sql.SQLException
Clears the current parameter values immediately.

In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method clearParameters.

Throws:
java.sql.SQLException - if a database access error occurs


Copyright (c) 2000, 2001, David Walend