FileDocCategorySizeDatePackage
SimpleTextPreparedStatement.javaAPI DocExample26592Sat Feb 03 11:43:42 GMT 2001jdbc.SimpleText

SimpleTextPreparedStatement

public class SimpleTextPreparedStatement extends SimpleTextStatement implements PreparedStatement

Fields Summary
Constructors Summary
Methods Summary
public voidclearParameters()

        // Clear all the bound parameters

        boundParams.clear();
    
public booleanexecute()

        resultSetColumns = null;

        // First, parse the sql statement into a String array

        parsedSQL = ownerConnection.parseSQL(sqlStatement);

        // Now validate the SQL statement and execute it.
        // Returns true if a result set exists.

        boolean rc = prepare(false);

        return rc;
    
public booleanexecute(java.lang.String sql)

        throw new SQLException("Method is not valid");
    
public java.sql.ResultSetexecuteQuery()

        if (traceOn()) {
            trace("@executeQuery()");
        }

        java.sql.ResultSet rs = null;

        // Execute the query.  If execute returns true, then a result set
        // exists

        if (execute()) {
            rs = getResultSet();
        }

        return rs;
    
public java.sql.ResultSetexecuteQuery(java.lang.String sql)

        throw new SQLException("Method is not valid");
    
public intexecuteUpdate()

        if (traceOn()) {
            trace("@executeUpdate()");
        }

        int count = -1;

        // Execute the query.  If execute returns false, then an update
        // count exists.

        if (execute() == false) {
            count = getUpdateCount();
        }

        return count;
    
public intexecuteUpdate(java.lang.String sql)

        throw new SQLException("Method is not valid");
    
protected intgetObjectType(java.lang.Object x)


        // Determine the data type of the Object by attempting to cast
        // the object.  An exception will be thrown if an invalid casting
        // is attempted.

        try {
            if ((String) x != null) {
                return Types.VARCHAR;
            }
        }
        catch (Exception ex) {
        }

        try {
            if ((Integer) x != null) {
                return Types.INTEGER;
            }
        }
        catch (Exception ex) {
        }

        try {
            if ((byte[]) x != null) {
                return Types.VARBINARY;
            }
        }
        catch (Exception ex) {
        }

        throw new SQLException("Unknown object type");
    
public voidinitialize(SimpleTextIConnection con, java.lang.String sql)

        super.initialize(con);

        // Save the SQL statement

        sqlStatement = sql;

        // To prepare the statement, we must parse and validate.  The act
        // of preparing does nothing more than validate the statement; it
        // does not save an execution plan.  When the prepared statement is
        // executed, it is re-parsed and re-validated each time.

        parsedSQL = ownerConnection.parseSQL(sql);

        // Prepare the statement, indicating the we are only preparing

        prepare(true);

        // Create a new boundParams Hashtable

        boundParams = new Hashtable();
    
public voidsetAsciiStream(int parameterIndex, java.io.InputStream x, int length)

        // Only binary InputStreams are current supported

        throw DataTypeNotSupported();
    
public voidsetBigDecimal(int parameterIndex, java.math.BigDecimal x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetBinaryStream(int parameterIndex, java.io.InputStream x, int length)

        // Validate the parameter index

        verify(parameterIndex);

        // Read in the entire InputStream all at once.  A more optimal
        // way of handling this would be to defer the read until execute
        // time, and only read in chunks at a time.

        byte b[] = new byte[length];

        try {
            x.read(b);
        }
        catch (Exception ex) {
            throw new SQLException("Unable to read InputStream: " +
                                ex.getMessage());
        }

        // Set the data as a byte array

        setBytes(parameterIndex, b);
    
public voidsetBoolean(int parameterIndex, boolean x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetByte(int parameterIndex, byte x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetBytes(int parameterIndex, byte[] x)

        // Validate the parameter index

        verify(parameterIndex);

        // Put the parameter into the boundParams Hashtable.  Coerce the
        // data into a String

        boundParams.put(new Integer(parameterIndex),
                                    (new CommonValue(x)).getString());
    
public voidsetDate(int parameterIndex, java.sql.Date x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetDouble(int parameterIndex, double x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetFloat(int parameterIndex, float x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetInt(int parameterIndex, int x)

        // Validate the parameter index

        verify(parameterIndex);

        // Put the parameter into the boundParams Hashtable.  Coerce the
        // data into a String

        boundParams.put(new Integer(parameterIndex),
                                    (new CommonValue(x)).getString());
    
public voidsetLong(int parameterIndex, long x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetNull(int parameterIndex, int sqlType)

        // The SimpleText driver does not support null values

        throw DriverNotCapable();
    
public voidsetObject(int parameterIndex, java.lang.Object x, int targetSqlType, int scale)

//TODO
    
public voidsetObject(int parameterIndex, java.lang.Object x, int targetSqlType)

        setObject(parameterIndex, x, targetSqlType, 0);
    
public voidsetObject(int parameterIndex, java.lang.Object x)

        // We don't handle nulls

        if (x == null) {
            throw new SQLException("Null values are not supported");
        }

        // Determine the data type of the object.  We'll do this by attempting
        // to cast the given Object to the data types that are supported.

        int type = getObjectType(x);

        setObject(parameterIndex, x, type);
    
public voidsetShort(int parameterIndex, short x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetString(int parameterIndex, java.lang.String x)

        // Validate the parameter index

        verify(parameterIndex);

        // Put the parameter into the boundParams Hashtable

        boundParams.put(new Integer(parameterIndex), x);
    
public voidsetTime(int parameterIndex, java.sql.Time x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetTimestamp(int parameterIndex, java.sql.Timestamp x)

        // The SimpleText driver does not support this data type.  We could
        // coerce the data, but an exception is will be thrown for now.

        throw DataTypeNotSupported();
    
public voidsetUnicodeStream(int parameterIndex, java.io.InputStream x, int length)

        // Only binary InputStreams are current supported

        throw DataTypeNotSupported();
    
protected voidverify(int parameterIndex)

        clearWarnings();

        // The paramCount was set when the statement was prepared

        if ((parameterIndex <= 0) ||
            (parameterIndex > paramCount)) {
            throw new SQLException("Invalid parameter number: " +
                                        parameterIndex);
        }

        // If the parameter has already been set, clear it

        if (boundParams.get(new Integer(parameterIndex)) != null) {
            boundParams.remove(new Integer(parameterIndex));
        }