Mimer JDBC/MIDP 2.12

com.mimer.jdbc
Class PreparedStatement

java.lang.Object
  |
  +--com.mimer.jdbc.Statement
        |
        +--com.mimer.jdbc.PreparedStatement
Direct Known Subclasses:
CallableStatement

public class PreparedStatement
extends Statement

A PreparedStatement contains a pre-compiled SQL statement which may have parameter markers. The statement may be executed several times with different parameters without having to recompile the SQL syntax.

Statements with output parameters may not be executed using this object.

See ResultSet for information on which Mimer SQL data types may be set with which setter method.


Method Summary
 void addBatch()
          Adds a set of input parameters to a PreparedStatement batch.
 void clearBatch()
          Clears the current batch.
 void clearParameters()
          Clears the currently set parameters.
 void close()
          Closes the PreparedStatement.
 boolean execute()
          Execute the prepared statement with the current set of parameters.
 int[] executeBatch()
          Executing the current batch.
 ResultSet executeQuery()
          Executes a query that returns a result set.
 int executeUpdate()
          Executes an SQL-statement that don't return a result set.
 ResultSetMetaData getMetaData()
          Returns a ResultSetMetaData object describing the result sets that will be returned when this object is executed.
 void setAsciiStream(int parameterIndex, java.io.InputStream x, int length)
          Sets the specified parameter to the contents of the supplied stream.
 void setBinaryStream(int parameterIndex, java.io.InputStream x, int length)
          Sets the specified parameter to the contents of the supplied stream.
 void setBlob(int parameterIndex, Blob x)
          Set an Blob object.
 void setBoolean(int parameterIndex, boolean x)
          Sets a boolean parameter value.
 void setByte(int parameterIndex, byte x)
          Sets the specified column to the value of a byte.
 void setBytes(int parameterIndex, byte[] x)
           
 void setCharacterStream(int parameterIndex, java.io.Reader x, int length)
          Sets the specified column to the contents of the supplied stream.
 void setClob(int parameterIndex, Clob x)
          Set a Clob object.
 void setInt(int parameterIndex, int x)
          Sets the specified column to the value of a int.
 void setLong(int parameterIndex, long x)
          Sets the specified column to the value of a long.
 void setNull(int parameterIndex, int sqlType)
          Set a parameter to null.
 void setNull(int parameterIndex, int sqlType, java.lang.String typeName)
          Set a parameter to null.
 void setObject(int parameterIndex, java.lang.Object x)
          Sets the specified column to the value of a Object.
 void setObject(int parameterIndex, java.lang.Object x, int targetSqlType)
          Sets the specified column to the value of a Object.
 void setObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale)
          Sets the specified column to the value of a Object.
 void setShort(int parameterIndex, short x)
          Sets the specified column to the value of a short.
 void setString(int parameterIndex, java.lang.String x)
          Sets the specified column to the value of string.
 
Methods inherited from class com.mimer.jdbc.Statement
addBatch, cancel, clearWarnings, execute, executeQuery, executeUpdate, getConnection, getFetchDirection, getFetchSize, getMaxFieldSize, getMaxRows, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetType, getUpdateCount, getWarnings, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setMaxFieldSize, setMaxRows, setQueryTimeout
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addBatch

public void addBatch()
              throws SQLException
Adds a set of input parameters to a PreparedStatement batch.

See Statement.addBatch for a discussion on the difference between Statement batches and PreparedStatement batches.

Throws:
SQLException - if an error occurs. If the PreparedStatement object is not open, SQLSTATE HY010 is thrown. HY010 is also thrown when the PreparedStatement is not an INSERT, UPDATE or DELETE SQL statement.

See Also:
executeBatch()

clearBatch

public void clearBatch()
                throws SQLException
Clears the current batch.

Overrides:
clearBatch in class Statement
Throws:
SQLException - if an error occurs. If the Statement object is closed, SQLSTATE HY010 is thrown.
See Also:
addBatch(java.lang.String), executeBatch()

clearParameters

public void clearParameters()
                     throws SQLException
Clears the currently set parameters.

Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement wasn't open.

close

public void close()
           throws SQLException
Closes the PreparedStatement.

Overrides:
close in class Statement
Throws:
SQLException - if an error occurs.

execute

public boolean execute()
                throws SQLException
Execute the prepared statement with the current set of parameters.

Returns:
True if a result set was returned. If so use the getResultSet method to obtain the ResultSet object.
Throws:
SQLException - if an error occurs. HY010 is thrown if the statement is not open, or if there where batches added to this PreparedStatement. HY000 is thrown if the statement contains parameter markers, in this case you must use a PreparedStatement object instead. HY000 may also be thrown when the SQL statement was not supported by the driver, see Statement for an overview on which statements that are not supported and why. 42000 is thrown if the SQL contained a syntax error. 34000 is thrown if a UPDATE/DELETE WHERE CURRENT OF specified a cursor that doesn't exist. S1008 is thrown if the execution is cancelled.
See Also:
executeUpdate(java.lang.String), executeQuery(java.lang.String), Statement.getResultSet()

executeBatch

public int[] executeBatch()
                   throws SQLException
Executing the current batch.

Overrides:
executeBatch in class Statement
Returns:
An integer array containing update counts of each set of parameter.
Throws:
SQLException - if an error occurs. If the PreparedStatement object is not open, SQLSTATE HY010 is thrown. This call may execute a lot of server side code and may return any server runtime error. S1008 is thrown if the execution is cancelled.
See Also:
addBatch(java.lang.String)

executeQuery

public ResultSet executeQuery()
                       throws SQLException
Executes a query that returns a result set.

Returns:
The update count.
Throws:
SQLException - if an error occurs. HY010 is thrown if the statement is not open. HY000 is thrown if the statement contains parameter markers, in this case you must use a PreparedStatement object instead. HY000 may also be thrown when the SQL statement was not supported by the driver, see Statement for an overview on which statements that are not supported and why. 42000 is thrown if the SQL contained a syntax error or the statement wasn't a query. 34000 is thrown if a UPDATE/DELETE WHERE CURRENT OF specified a cursor that doesn't exist. S1008 is thrown if the execution is cancelled.
See Also:
executeUpdate(java.lang.String), execute(java.lang.String)

executeUpdate

public int executeUpdate()
                  throws SQLException
Executes an SQL-statement that don't return a result set.

Returns:
The update count.
Throws:
SQLException - if an error occurs. HY010 is thrown if the statement is not open. HY000 is thrown if the statement contains parameter markers, in this case you must use a PreparedStatement object instead. HY000 may also be thrown when the SQL statement was not supported by the driver, see Statement for an overview on which statements that are not supported and why. 42000 is thrown if the SQL contained a syntax error or the statement was a query. 34000 is thrown if a UPDATE/DELETE WHERE CURRENT OF specified a cursor that doesn't exist. S1008 is thrown if the execution is cancelled.
See Also:
executeQuery(java.lang.String), execute(java.lang.String)

getMetaData

public ResultSetMetaData getMetaData()
                              throws SQLException
Returns a ResultSetMetaData object describing the result sets that will be returned when this object is executed.

A ResultSetMetaData object is always internally created at the same time the PreparedStatement object is created. This method simply returns this object.

Returns:
The ResultSetMetaData object. If the PreparedStatement was not a query, null is returned.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the cursor is not open.

setAsciiStream

public void setAsciiStream(int parameterIndex,
                           java.io.InputStream x,
                           int length)
                    throws SQLException
Sets the specified parameter to the contents of the supplied stream.

Parameters:
parameterIndex - The parameter number.
x - The data.
length - The length of the data. This is ignored for all parameter types except CLOB:s. When inserting CLOB data, the server want to know the length of the data in advance. There is no way to use this method to insert CLOB:s larger than 2 GB. To insert larger CLOB:s, use Clob objects instead which from JDBC 3 includes methods for this.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22001 if the stream was shorter than specified. HY000 if there was a read eror in the supplied InputStream.
DataTruncation - if the input stream was longer than the parameter could hold.

setBinaryStream

public void setBinaryStream(int parameterIndex,
                            java.io.InputStream x,
                            int length)
                     throws SQLException
Sets the specified parameter to the contents of the supplied stream.

Parameters:
parameterIndex - The parameter number.
x - The data.
length - The length of the data in bytes. This is ignored for all parameter types except BLOB:s. When inserting BLOB data, the server want to know the length of the data in advance. There is no way to use this method to insert BLOB:s larger than 2 GB. To insert larger BLOB:s, use Blob objects instead which from JDBC 3 includes methods for this.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22001 if the stream was shorter than specified. HY000 if there was a read eror in the supplied InputStream.
DataTruncation - if the input stream was longer than the parameter could hold.

setBlob

public void setBlob(int parameterIndex,
                    Blob x)
             throws SQLException
Set an Blob object.

Parameters:
parameterIndex - The column index.
x - The Blob object.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement is not open. 07009 is thrown if the parameterIndex is not valid. 2200G is thrown if the column type wasn't castable from a Blob object, see {link ResultSet} for an overview of which Java types are castable to which SQL types.

setBoolean

public void setBoolean(int parameterIndex,
                       boolean x)
                throws SQLException
Sets a boolean parameter value.

Mimer SQL does not support a SQL BOOLEAN data type. When the setBoolean is used to set parameter values, the following values will be used:
truefalse
character data types"true""false"
numerical data types10

Parameters:
parameterIndex - The parameter number.
x - The boolean value.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

setByte

public void setByte(int parameterIndex,
                    byte x)
             throws SQLException
Sets the specified column to the value of a byte.

Parameters:
parameterIndex - The parameter number.
x - The byte.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

setBytes

public void setBytes(int parameterIndex,
                     byte[] x)
              throws SQLException
SQLException

setCharacterStream

public void setCharacterStream(int parameterIndex,
                               java.io.Reader x,
                               int length)
                        throws SQLException
Sets the specified column to the contents of the supplied stream.

If the parameter type is a latin1-based character string and the stream contains characters that cannot be converted to a latin1 (ISO 8859-1) based string, an SQLException is thrown.

Parameters:
parameterIndex - The parameter number.
x - The data.
length - The length of the input stream in characters. This is ignored for all parameter types except CLOB:s. When inserting CLOB data, the server want to know the length of the data in advance. There is no way to use this method to insert CLOB:s larger than 2 GB. JDBC 3 offers a a way to work with objects larger than 2 GB through the Clob object.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement is not open. 07009 is thrown if the parameterIndex is not valid. 2200G is thrown if the column type wasn't castable from a character stream, see {link ResultSet} for an overview of which Java types are castable to which SQL types.

setClob

public void setClob(int parameterIndex,
                    Clob x)
             throws SQLException
Set a Clob object.

Parameters:
parameterIndex - The column index.
x - The Clob object.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement is not open. 07009 is thrown if the parameterIndex is not valid. 2200G is thrown if the column type wasn't castable from a Clob object, see {link ResultSet} for an overview of which Java types are castable to which SQL types.

setInt

public void setInt(int parameterIndex,
                   int x)
            throws SQLException
Sets the specified column to the value of a int.

Parameters:
parameterIndex - The parameter number.
x - The int.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

setLong

public void setLong(int parameterIndex,
                    long x)
             throws SQLException
Sets the specified column to the value of a long.

Parameters:
parameterIndex - The parameter number.
x - The long.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

setNull

public void setNull(int parameterIndex,
                    int sqlType)
             throws SQLException
Set a parameter to null.

Parameters:
parameterIndex - The column index.
sqlType - The SQL type of the column. A value from Types.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement is not open. 07009 is thrown if the parameterIndex is not valid. 23000 is thrown if the parameter wasn't nullable.

setNull

public void setNull(int parameterIndex,
                    int sqlType,
                    java.lang.String typeName)
             throws SQLException
Set a parameter to null.

This version of the setNull is supposed to be used on user-defined types and REF type parameters. Mimer SQL servers up until 9.2 including this driver does not support these SQL datatypes. The sqlType and typeName parameters are ignored.

Parameters:
parameterIndex - The column index.
sqlType - The SQL type of the column. A value from Types.
typeName - The name of the type.
Throws:
SQLException - if an error occurs. SQLSTATE HY010 is thrown if the PreparedStatement is not open. 07009 is thrown if the parameterIndex is not valid. 23000 is thrown if the parameter wasn't nullable.

setObject

public void setObject(int parameterIndex,
                      java.lang.Object x)
               throws SQLException
Sets the specified column to the value of a Object.

Parameters:
parameterIndex - The parameter number.
x - The object.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. This method may throw most SQLSTATE:s thrown by the other setter methods of this object.

setObject

public void setObject(int parameterIndex,
                      java.lang.Object x,
                      int targetSqlType)
               throws SQLException
Sets the specified column to the value of a Object.

Parameters:
parameterIndex - The parameter number.
x - The object.
targetSqlType -
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. This method may throw most SQLSTATE:s thrown by the other setter methods of this object.

setObject

public void setObject(int parameterIndex,
                      java.lang.Object x,
                      int targetSqlType,
                      int scale)
               throws SQLException
Sets the specified column to the value of a Object.

Parameters:
parameterIndex - The parameter number.
x - The object.
targetSqlType -
scale -
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. This method may throw most SQLSTATE:s thrown by the other setter methods of this object.

setShort

public void setShort(int parameterIndex,
                     short x)
              throws SQLException
Sets the specified column to the value of a short.

Parameters:
parameterIndex - The parameter number.
x - The short.
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

setString

public void setString(int parameterIndex,
                      java.lang.String x)
               throws SQLException
Sets the specified column to the value of string.

Parameters:
parameterIndex - The parameter number.
x - The String
Throws:
SQLException - if an error occurs. SQLSTATE 07009 is thrown if the parameter does not exist. HY010 if the PreparedStatement is not open. 2200G if this method can't be used to convert to the server data type. 22003 if the server data type was a numeric data type and the value was larger than the data type could hold. 22001 if the server data type was a character string and the value could not be fitted into the string.

Mimer JDBC/MIDP 2.12

Submit a comment or suggestion Version 2.12 of Mimer JDBC for the CLDC/MID Profile Specification
Copyright Upright Database Technology AB, Box 1713, SE-751 47 UPPSALA, Sweden. All Rights Reserved.