Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class org.gjt.mm.mysql.PreparedStatement

java.lang.Object
  |
  +--org.gjt.mm.mysql.Statement
        |
        +--org.gjt.mm.mysql.PreparedStatement

public class PreparedStatement
extends Statement
implements java.sql.PreparedStatement

Constructor Summary
PreparedStatement(Connection Conn, java.lang.String Sql)
          Constructor for the PreparedStatement class.
 
Method Summary
void clearParameters()
          In general, parameter values remain in force for repeated used of a Statement.
boolean execute()
          Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by executeQuery and executeUpdate
java.sql.ResultSet executeQuery()
          A Prepared SQL query is executed and its ResultSet is returned
int executeUpdate()
          Execute a SQL INSERT, UPDATE or DELETE statement.
void setAsciiStream(int parameterIndex, java.io.InputStream X, int length)
          When a very large ASCII value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.
void setBigDecimal(int parameterIndex, java.math.BigDecimal X)
          Set a parameter to a java.lang.
void setBinaryStream(int parameterIndex, java.io.InputStream X, int length)
          When a very large binary value is input to a LONGVARBINARY parameter, it may be more practical to send it via a java.io.
void setBoolean(int parameterIndex, boolean x)
          Set a parameter to a Java boolean value.
void setByte(int parameterIndex, byte x)
          Set a parameter to a Java byte value.
void setBytes(int parameterIndex, byte[] x)
          Set a parameter to a Java array of bytes.
void setDate(int parameterIndex, java.sql.Date X)
          Set a parameter to a java.sql.
void setDouble(int parameterIndex, double x)
          Set a parameter to a Java double value.
void setFloat(int parameterIndex, float x)
          Set a parameter to a Java float value.
void setInt(int parameterIndex, int x)
          Set a parameter to a Java int value.
void setLong(int parameterIndex, long x)
          Set a parameter to a Java long value.
void setNull(int parameterIndex, int sqlType)
          Set a parameter to SQL NULL

Note: You must specify the parameters SQL type (although PostgreSQL ignores it)

void setObject(int parameterIndex, java.lang.Object X, int targetSqlType, int scale)
          Set the value of a parameter using an object; use the java.lang equivalent objects for integral values.
void setObject(int parameterIndex, java.lang.Object X, int targetSqlType)
           
void setObject(int parameterIndex, java.lang.Object X)
           
void setShort(int parameterIndex, short x)
          Set a parameter to a Java short value.
void setString(int parameterIndex, java.lang.String X)
          Set a parameter to a Java String value.
void setTime(int parameterIndex, java.sql.Time X)
          Set a parameter to a java.sql.
void setTimestamp(int parameterIndex, java.sql.Timestamp X)
          Set a parameter to a java.sql.
void setUnicodeStream(int parameterIndex, java.io.InputStream X, int length)
          When a very large Unicode value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.
 
Methods inherited from class org.gjt.mm.mysql.Statement
cancel, clearWarnings, close, executeQuery, execute, executeUpdate, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Constructor Detail

PreparedStatement

public PreparedStatement(Connection Conn,
                         java.lang.String Sql)
                  throws java.sql.SQLException
Constructor for the PreparedStatement class. Split the SQL statement into segments - separated by the arguments. When we rebuild the thing with the arguments, we can substitute the args and join the whole thing together.
Parameters:
conn - the instanatiating connection
sql - the SQL statement with ? for IN markers
Throws:
java.sql.SQLException - if something bad occurs
Method Detail

executeQuery

public java.sql.ResultSet executeQuery()
                               throws java.sql.SQLException
A Prepared SQL query is executed and its ResultSet is returned
Specified by:
executeQuery() in interface java.sql.PreparedStatement
Returns:
a ResultSet that contains the data produced by the query - never null
Throws:
java.sql.SQLException - if a database access error occurs

executeUpdate

public int executeUpdate()
                 throws java.sql.SQLException
Execute a SQL INSERT, UPDATE or DELETE statement. In addition, SQL statements that return nothing such as SQL DDL statements can be executed.
Specified by:
executeUpdate() in interface java.sql.PreparedStatement
Returns:
either the row count for INSERT, UPDATE or DELETE; or 0 for SQL statements that return nothing.
Throws:
java.sql.SQLException - if a database access error occurs

setNull

public void setNull(int parameterIndex,
                    int sqlType)
            throws java.sql.SQLException
Set a parameter to SQL NULL

Note: You must specify the parameters SQL type (although PostgreSQL ignores it)

Specified by:
setNull(int, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1, etc...
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
Set a parameter to a Java boolean value. The driver converts this to a SQL BIT value when it sends it to the database.
Specified by:
setBoolean(int, boolean) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java byte value. The driver converts this to a SQL TINYINT value when it sends it to the database.
Specified by:
setByte(int, byte) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java short value. The driver converts this to a SQL SMALLINT value when it sends it to the database.
Specified by:
setShort(int, short) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java int value. The driver converts this to a SQL INTEGER value when it sends it to the database.
Specified by:
setInt(int, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java long value. The driver converts this to a SQL BIGINT value when it sends it to the database.
Specified by:
setLong(int, long) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java float value. The driver converts this to a SQL FLOAT value when it sends it to the database.
Specified by:
setFloat(int, float) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java double value. The driver converts this to a SQL DOUBLE value when it sends it to the database
Specified by:
setDouble(int, double) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBigDecimal

public void setBigDecimal(int parameterIndex,
                          java.math.BigDecimal X)
                  throws java.sql.SQLException
Set a parameter to a java.lang.BigDecimal value. The driver converts this to a SQL NUMERIC value when it sends it to the database.
Specified by:
setBigDecimal(int, java.math.BigDecimal) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setString

public void setString(int parameterIndex,
                      java.lang.String X)
              throws java.sql.SQLException
Set a parameter to a Java String value. The driver converts this to a SQL VARCHAR or LONGVARCHAR value (depending on the arguments size relative to the driver's limits on VARCHARs) when it sends it to the database.
Specified by:
setString(int, java.lang.String) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a Java array of bytes. The driver converts this to a SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARYs) when it sends it to the database.
Specified by:
setBytes(int, byte[]) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
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
Set a parameter to a java.sql.Date value. The driver converts this to a SQL DATE value when it sends it to the database.
Specified by:
setDate(int, java.sql.Date) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setTime

public void setTime(int parameterIndex,
                    java.sql.Time X)
            throws java.sql.SQLException
Set a parameter to a java.sql.Time value. The driver converts this to a SQL TIME value when it sends it to the database.
Specified by:
setTime(int, java.sql.Time) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...));
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
Set a parameter to a java.sql.Timestamp value. The driver converts this to a SQL TIMESTAMP value when it sends it to the database.
Specified by:
setTimestamp(int, java.sql.Timestamp) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setAsciiStream

public void setAsciiStream(int parameterIndex,
                           java.io.InputStream X,
                           int length)
                   throws java.sql.SQLException
When a very large ASCII value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from ASCII to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setAsciiStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
length - the number of bytes in the stream
Throws:
java.sql.SQLException - if a database access error occurs

setUnicodeStream

public void setUnicodeStream(int parameterIndex,
                             java.io.InputStream X,
                             int length)
                     throws java.sql.SQLException
When a very large Unicode value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file. The JDBC driver will do any necessary conversion from UNICODE to the database char format.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setUnicodeStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

setBinaryStream

public void setBinaryStream(int parameterIndex,
                            java.io.InputStream X,
                            int length)
                    throws java.sql.SQLException
When a very large binary value is input to a LONGVARBINARY parameter, it may be more practical to send it via a java.io.InputStream. JDBC will read the data from the stream as needed, until it reaches end-of-file.

Note: This stream object can either be a standard Java stream object or your own subclass that implements the standard interface.

Specified by:
setBinaryStream(int, java.io.InputStream, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the parameter value
Throws:
java.sql.SQLException - if a database access error occurs

clearParameters

public void clearParameters()
                    throws java.sql.SQLException
In general, parameter values remain in force for repeated used of a Statement. Setting a parameter value automatically clears its previous value. However, in coms cases, it is useful to immediately release the resources used by the current parameter values; this can be done by calling clearParameters
Specified by:
clearParameters() in interface java.sql.PreparedStatement
Throws:
java.sql.SQLException - if a database access error occurs

setObject

public void setObject(int parameterIndex,
                      java.lang.Object X,
                      int targetSqlType,
                      int scale)
              throws java.sql.SQLException
Set the value of a parameter using an object; use the java.lang equivalent objects for integral values.

The given Java object will be converted to the targetSqlType before being sent to the database.

note that this method may be used to pass database-specific abstract data types. This is done by using a Driver-specific Java type and using a targetSqlType of java.sql.Types.OTHER

Specified by:
setObject(int, java.lang.Object, int, int) in interface java.sql.PreparedStatement
Parameters:
parameterIndex - the first parameter is 1...
x - the object containing the input parameter value
targetSqlType - The SQL type to be send to the database
scale - For java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types this is the number of digits after the decimal. For all other types this value will be ignored.
Throws:
java.sql.SQLException - if a database access error occurs

setObject

public void setObject(int parameterIndex,
                      java.lang.Object X,
                      int targetSqlType)
              throws java.sql.SQLException
Description copied from interface:
 
Specified by:
setObject(int, java.lang.Object, int) in interface java.sql.PreparedStatement

setObject

public void setObject(int parameterIndex,
                      java.lang.Object X)
              throws java.sql.SQLException
Description copied from interface:
 
Specified by:
setObject(int, java.lang.Object) in interface java.sql.PreparedStatement

execute

public boolean execute()
               throws java.sql.SQLException
Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by executeQuery and executeUpdate
Specified by:
execute() in interface java.sql.PreparedStatement
Returns:
true if the next result is a ResultSet; false if it is an update count or there are no more results
Throws:
java.sql.SQLException - if a database access error occurs

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD