MDi JLib
1.7.4

com.microdeveloper.data
Class SQLDataSet

java.lang.Object
  extended by com.microdeveloper.data.SQLDataSet

public class SQLDataSet
extends Object

The implementation of the SQLSet, a java.sql.ResultSet which is wrapped in a self contained object with connection information, sql basis, sql parameters, and meta information related to a ResultSet.

The functionality of the class allows the class to be treated much like a simple collection with update capability.  Updates are not performed on the object itself but rather through DML statements in the SQL property.

The class provides methods for manipulating the results of the Sql in a convienient manner and provides the following capabilities:

The parameters for the SQL call are flexible in that they can be as generic as an array of Strings, set individually, or passed in as a batch.  Unlike the SQL driver construct for a statement or prepared statement, you do not need to make a particularly named call to set a variable.  For example:
JDBC norm:

 Connection conn = DriverManager...
 PreparedStatment ps = conn.prepareStatement (sql);
 ps.setString(1, "My Value");

SQLDataSet:
 Connection conn = DriverManager...
 SQLDataSet ds = new SQLDataSet(conn, sql);
 ds.setParameter(1, java.sql.Types.VARCHAR, "My Value");

To iterate over a SQLDataSet simply use the traditional JDBC methods. For example:

while (ds.next()) {
   System.out.println("Column foo: " + ds.getString("foo"));
   ...
 }

One area of confusion can come from setting primitive types such as int.  You can use setInt(int, int), but because setParameter takes an Object as an argument and int must be passed in as an Java object such as Integer by using Integer.valueOf(int).     Almost all primary and extended jdbc types are supported but only a limited set are supported by the setParameter call.  If you attempt to use a type that is not supported, you will get an UnsupportedSQLType exception.  The following types are supported by setParameter:
SQL type (Java type): DATE (Date), INTEGER (Integer), DOUBLE (Double), FLOAT (Float), NUMERIC (Double), TIMESTAMP (Timestamp), VARCHAR (String)

So, if you can use the native parameter call why use setParameter?  SetParameter does more than just set the argument in one call, it also examines the contents you pass in and automatically adjusts the value to the appropriate setNull call when the value given is, in fact, null.  Because of this, you need not test for null and then programmatically set the appropriate call and SQLType. Mearly make a call to setParameter passing in the value (null or not), and the method will setup the rest.

Note: Arguments are being deprecated and removed from this class in favor of using parameters in the traditional jdbc sense. When passing in arguments in batches, use ArrayList objects to represent the components. You must provide 3 lists: name list, type list, and value list. Each must have the same number of entries and corresponding positioning. Arguments may also be set as an array of Strings which is treated as VARCHAR object types for DML purposes. Finally, it is also possible to simply call setArg(String) for very simple calls where there is only one argument. The type is assumed to be VARCHAR, the value is the String given, and the position is the first (and only) parameter.

Arguments set manually, in batches or through a direct call to query or update, are synchronized with the parameters, however the inverse is not true. If you set the parameters directly through setParameter or setXYZ where XYZ is the type (e.g., setInt), the argument list is not updated. The call to getParameterMetaData will always return the currently established parameter list.

Important:  Always close the SQLDataSet when you are done using it. Failure to do so will result in a cursor leak which, if nested, could cause the database to run out of memory of throw internal errors. Closing the connection alone does not always free up cursors, and combined with certain drivers, will not cleanup cursors when used with Connection pooling even if the resultset is explicitly destroyed. Therefore always ensure that the ResultSet is released along with the PreparedStatement by using the close() method which will take care of releasing both immediately.

Since:
1.1
Version:
1.6
Author:
MicroDeveloper, Inc.

Constructor Summary
SQLDataSet()
          Initializes a new instance of SQLDataSet.
SQLDataSet(Connection conn, String sql)
          Initializes a new instance of SQLDataSeta and establishes the connection and statement.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Creates a property change listener
 void afterLast()
          Moves the ResultSet cursor after the last record
 void beforeFirst()
          Moves the ResultSet cursor before the 1st record
 void clearArgs()
          Sets the current arguments and parameters to empty (null)
 void close()
          Closes the ResultSet thereby freeing the cursors.
 boolean doCommit()
          Performs a commit action within the database connection.
 boolean doRollback()
          Performs a rollback action within the database connection.
 boolean doRollback(Savepoint sp)
          Performs a rollback action within the database connection.
 ResultSet executeQuery()
          Establishes and returns the ResultSet based on the SQL property value and the established parameters using the established Connection property.
 int executeUpdate()
          Executes the SQL statement in this SQL property value, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
 void finalize()
          Cleans out the instance during garbage collection.
 void first()
          Moves the cursor position to the first record in the ResultSet.
 ArrayList getArguments(String type)
          Deprecated. as of 1.5 may be removed from future versions
 boolean getAutoCommit()
          Returns the current state of automatic commit processing.
 boolean getAutoRollback()
          Returns the current state of automatic rollback functionality.
 BigDecimal getBigDecimal(String columnName)
          Gets a BigDecimal value from the current row based on the name of the column desired.
 Blob getBlob(String columnName)
          Gets a Blob (Binary Large Object Block) object from the current row based on the name of the column desired.
 Clob getClob(String columnName)
          Gets a Clob (Character Large Object Block) object from the current row based on the name of the column desired.
 int getColumnCount()
          Gets the number of columns in the ResultSet
 String getColumnName(int i)
          Gets the name of the column as indicated by the position of the column (i) within the ResultSet.
 String[] getColumnNames()
          Gets the column names from the current ResultSet and returns them as a string array
 int getColumnPosition(String columnName)
          Gets the position of a column in the resultset given the name of the column.
 String getColumnType(int i)
          Gets the type of a particular column in the ResultSet by numeric position
 String getColumnType(String columnName)
          Gets the database type of column in the selected drivers meta-data notation.
 boolean getCommitting()
          Returns the current state of commit processing.
 Connection getConnection()
          Gets the connection object for this instantiation.
 String getConnectionURL()
          Gets the URL that describes or represents this jdbc connection.
 Connection getConnProperty()
          Gets the current database connection object
 int getCurrentRow()
          Deprecated. As of release 1.5, replaced by getRow() may be removed from future versions
 SQLSet getDataSetInterface()
          Establishes the interface to a SQLDataSetInterface.
 Date getDate(String columnName)
          Gets a Date value from the current row based on the name of the column desired using the default Calendar.
 Date getDate(String columnName, Calendar cal)
          Gets a Date value from the current row based on the name of the column desired using the Calendar specified.
 double getDouble(String columnName)
          Gets a Double value from the current row based on the name of the column desired.
 float getFloat(String columnName)
          Gets a Float value from the current row based on the name of the column desired.
 int getInt(String columnName)
          Gets a Integer value from the current row based on the name of the column desired.
 Object getObject(int i)
          Gets the column object specifed by integer position of the column for the current row.
 Object getObject(int row, int column)
          Gets the column object specifed by integer position of the row and column.
 Object getObject(int row, String columnName)
          Gets the column object specifed by integer position of the row and column.
 Object getObject(String columnName)
          Gets the column object specifed by column name for the current row in the recordset.
 ParameterMetaData getParameterMetaData()
          Retrieves the number, types and properties of this PreparedStatement object's parameters.
 ResultSet getResultSet()
          Gets the current java.sql.ResultSet
 int getRow()
          Gets in the position of the cursor within the ResultSet.
 int getRowCount()
          Gets the current number of rows in the ResultSet
 int getSize()
          Gets the number of rows in the current ResultSet
 String getSql()
          Gets the SQL currently set for this instance
 String getSqlProperty()
          Gets the currently established SQL property
 String getString(String columnName)
          Gets a String value from the current row based on the name of the column desired.
 String getTableName(int i)
          Gets the tablename from within the current resultset given the positional number of the table.
 Time getTime(String columnName)
          Gets a Time value from the current row based on the name of the column desired using the default Calendar.
 Time getTime(String columnName, Calendar cal)
          Gets a Time value from the current row based on the name of the column desired using the Calendar specified.
 boolean hasData()
          Gets the state of the ResultSet returning true if the ResultSet contains data, otherwise false.
 boolean isEmpty()
          Determines of the ResultSet is empty or not
 void last()
          Moves the cursor position to the last record in the ResultSet.
 boolean next()
          Moves the record set pointer forward by one record.
 void nextRecord()
          Deprecated. as of 1.7.1, replaced by next() may be removed from future versions
 boolean previous()
          Method previous will move the record set pointer backward by one record.
 void previousRecord()
          Deprecated. as of 1.7.1, replaced by previous() may be removed from future versions
 void query()
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void query(Connection conn, String sql)
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void query(Connection conn, String sql, String[] args)
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void query(String sql)
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void query(String[] args)
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void query(String sql, String[] args)
          Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions
 void releaseSavepoint(Savepoint sp)
          Releases a given savepoint.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a set property
 void setArg(String arg)
          Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)
 void setArgs(String[] args)
          Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)
 void setArguments(ArrayList nameList, ArrayList typeList, ArrayList valueList)
          Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)
 void setArray(int parameterIndex, Array x)
          Sets the designated parameter to the given Java int value.
 void setAsciiStream(int parameterIndex, InputStream x, int length)
          Sets the designated parameter to the given input stream, which will have the specified number of bytes.
 void setAutoCommit(boolean state)
          Turns automatic comitting on or off.
 void setAutoRollback(boolean state)
          Turns automatic rollback functionality on or off.
 void setBigDecimal(int parameterIndex, BigDecimal x)
          Sets the designated parameter to the given java.math.BigDecimal value.
 void setBinaryStream(int parameterIndex, InputStream x, int length)
          Sets the designated parameter to the given input stream, which will have the specified number of bytes.
 void setBlob(int parameterIndex, Blob x)
          Sets the designated parameter to the given java.sql.Blob value.
 void setBoolean(int parameterIndex, boolean x)
          Sets the designated parameter to the given Java boolean value.
 void setByte(int parameterIndex, byte x)
          Sets the designated parameter to the given Java byte value.
 void setBytes(int parameterIndex, byte[] x)
          Sets the designated parameter to the given Java array of bytes value.
 void setCharacterStream(int parameterIndex, Reader reader, int length)
          Sets the designated parameter to the given Reader object, which is the given number of characters long.
 void setClob(int parameterIndex, Clob x)
          Sets the designated parameter to the given java.sql.Clob value.
 void setCommitting(boolean state)
          Turns commit processing on or off.
 void setConnection(Connection c)
          Assigns the Connection c to this object to use for all operations
 void setConnProperty(Connection value)
          Sets the current database connection property.
 void setCurrentRow(int i)
          Sets the cursor position to an absolute row in the ResultSet
 void setData()
          Deprecated. As of release 1.2, replaced by query()
 void setData(Connection conn, String sql, String[] args)
          Deprecated. As of release 1.2, replaced by query(java.sql.Connection,String,String[])
 void setData(String[] args)
          Deprecated. As of release 1.2, replaced by query(String[])
 void setData(String sql, String[] args)
          Deprecated. As of release 1.2, replaced by query(String,String[])
 void setDate(int parameterIndex, Date x)
          Sets the designated parameter to the given java.sql.Date value.
 void setDate(int parameterIndex, Date x, Calendar cal)
          Sets the designated parameter to the given java.sql.Date value, using the given Calendar object.
 void setDouble(int parameterIndex, double x)
          Sets the designated parameter to the given Java double value.
 void setFloat(int parameterIndex, float x)
          Sets the designated parameter to the given Java float value.
 void setInt(int parameterIndex, int x)
          Sets the designated parameter to the given Java int value.
 void setLong(int parameterIndex, long x)
          Sets the designated parameter to the given Java long value.
 void setNull(int parameterIndex, int sqlType)
          Sets the designated parameter to SQL NULL.
 void setObject(int parameterIndex, Object x)
          Sets the value of the designated parameter using the given object.
 void setParameter(int parameterIndex, int sqlType, Object x)
          Sets a parameter for use in the subsequent query or update call by evaluating the type and object value passed in.
 void setRef(int parameterIndex, Ref x)
          Sets the designated parameter to the given REF() value.
protected  void setRowCount()
          Sets the current row count property to the size of the current record set.
 Savepoint setSavePoint()
          Sets an un-named savepoint in the current transaction.
 Savepoint setSavePoint(String s)
          Sets an named savepoint in the current transaction.
 void setShort(int parameterIndex, short x)
          Sets the designated parameter to the given Java short value.
 void setSql(String sql)
          Sets the SQL to use for performing queries to populate the ResultSet with.
 void setSqlProperty(String value)
          Sets the current SQL code property used in a query
 void setString(int parameterIndex, String x)
          Sets the designated parameter to the given Java String value.
 void setTime(int parameterIndex, Time x)
          Sets the designated parameter to the given java.sql.Time value value.
 void setTime(int parameterIndex, Time x, Calendar cal)
          Sets the designated parameter to the given java.sql.Time value, using the given Calendar object.
 void setTimestamp(int parameterIndex, Timestamp x)
          Sets the designated parameter to the given java.sql.Timestamp value.
 void setURL(int parameterIndex, URL x)
          Sets the designated parameter to the given java.net.URL value.
 Object[][] toObjectArray()
          Converts the resultset to a two dimensional array of primitive type java.lang.Object (Object [][]).
 String[][] toStringArray()
          Converts the resultset to a two dimensional array of type java.lang.String (String [][]).
 int update()
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 int update(Connection conn, String sql)
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 int update(Connection conn, String sql, String[] args)
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 int update(String sql)
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 int update(String[] args)
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 int update(String sql, String[] args)
          Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLDataSet

public SQLDataSet()
Initializes a new instance of SQLDataSet.


SQLDataSet

public SQLDataSet(Connection conn,
                  String sql)
           throws SQLException
Initializes a new instance of SQLDataSeta and establishes the connection and statement.

Parameters:
conn - an open connection to the database URL
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
Throws:
SQLException
Method Detail

getDataSetInterface

public SQLSet getDataSetInterface()
Establishes the interface to a SQLDataSetInterface.

Returns:
SQLSet object

finalize

public void finalize()
              throws Throwable
Cleans out the instance during garbage collection.

Overrides:
finalize in class Object
Throws:
Throwable

getArguments

public ArrayList getArguments(String type)
Deprecated. as of 1.5 may be removed from future versions

Gets the current set of arguments established for this data set. There are three types of argument lists; Names, Types, and Values. You may select the types by specifying all or part of the type name. For example, "Name", "NAME", "Na", "N" are all treated as type "Name".
  1. Name: The name of the parameter
  2. Type: The java type of the parameter
  3. Value: The current value of the parameter
Parameters are set using the setArguments method. However, parameters are also set as a result of using the method setData(Connection, String, String[]) or setData(String, String[]) or setData(String[]) methods. In this case the arguments are all treated as String arguments with a name of "anonymous".

Parameters:
type - One of the following (only first letter is relevant):
  • [N]ame
  • [T]ype
  • [V]alue
  • Returns:
    the requested argument list as a java.util.ArrayList object

    toObjectArray

    public Object[][] toObjectArray()
    Converts the resultset to a two dimensional array of primitive type java.lang.Object (Object [][]).

    Returns:
    an Object array representing the contents of the java.sql.ResultSet contents of this SQLDataSet object. If the resultset is empty or null then null is returned.

    toStringArray

    public String[][] toStringArray()
    Converts the resultset to a two dimensional array of type java.lang.String (String [][]). The first element representing the record and the second representing the column within the record.

    For example:
    mySqlDataSet[6][8] = the seventh record and the nineth column from the instance objects java.sql.ResultSet.

    Returns:
    a String array representing the contents of the java.sql.ResultSet contents of this SQLDataSet object. If the resultset is empty or null then null is returned.

    getConnection

    public Connection getConnection()
    Gets the connection object for this instantiation.

    Returns:
    connection object of type java.sql.Connection

    getConnectionURL

    public String getConnectionURL()
                            throws SQLException
    Gets the URL that describes or represents this jdbc connection.

    Returns:
    a URL string that describes this jdbc connection.
    Throws:
    SQLException - if the resultset does not exist or a database error occurs

    getColumnPosition

    public int getColumnPosition(String columnName)
    Gets the position of a column in the resultset given the name of the column. For example consider the SQL:

    select x, y, z from dual


    2 == getColumnPosition("y")

    Parameters:
    columnName - the text name of the column to find. The column name is not case sensitive.
    Returns:
    an integer representing the columns position in the resultset with 1 being the first position

    getTableName

    public String getTableName(int i)
    Gets the tablename from within the current resultset given the positional number of the table.

    For example, consider the following SQL:

    select a.x, a.y, b.z from table_a, table_b where ...


    "table_b" == getTableName(2)

    Parameters:
    i - the position of the table within the SQL. 1 equals the first table, 2 the second and so on.
    Returns:
    the text name of the table in the query (not the alias if one exists).

    getString

    public String getString(String columnName)
                     throws SQLException
    Gets a String value from the current row based on the name of the column desired. If the field is not a String it is converted to a String.

    Parameters:
    columnName - database column name, case insensitive
    Returns:
    value from the field in the record
    Throws:
    SQLException - Throws a general exception if unable to fetch the column

    getInt

    public int getInt(String columnName)
               throws SQLException
    Gets a Integer value from the current row based on the name of the column desired. If the field is not a Integer, or the record pointer is not positioned on a record, an exception will be thrown.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a int value
    Throws:
    SQLException - thrown when unable to fetch the value, null values have no effect

    getDate

    public Date getDate(String columnName)
                 throws SQLException
    Gets a Date value from the current row based on the name of the column desired using the default Calendar. If the field is not a Date, or the record pointer is not positioned on a record, an exception may be thrown or the date may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Date value
    Throws:
    SQLException - thrown when unable to fetch the value, null values have no effect
    See Also:
    getDate(String,java.util.Calendar)

    getFloat

    public float getFloat(String columnName)
                   throws SQLException
    Gets a Float value from the current row based on the name of the column desired. If the field is not a Float number, or the record pointer is not positioned on a record, an exception will be thrown. or the date may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Date value
    Throws:
    SQLException - thrown when unable to fetch the value or the value is not of type Float, null values have no effect

    getBigDecimal

    public BigDecimal getBigDecimal(String columnName)
                             throws SQLException
    Gets a BigDecimal value from the current row based on the name of the column desired. If the field is not a BigDecimal number, or the record pointer is not positioned on a record, an exception will be thrown.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a BigDecimal value
    Throws:
    SQLException - thrown when unable to fetch the value or the value is not of type BigDecimal or cannot be coerced to Big Decimal, null values have no effect

    getBlob

    public Blob getBlob(String columnName)
                 throws SQLException
    Gets a Blob (Binary Large Object Block) object from the current row based on the name of the column desired. If the field is not a Blob, or the record pointer is not positioned on a record, an exception will be thrown. The interpretation of the Blob is dependent on the underlying SQL driver used. The object returned is a generic sql.java.Blob object.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Blob object
    Throws:
    SQLException - thrown when unable to fetch the value or the value is not of type BLOB, null values have no effect

    getDate

    public Date getDate(String columnName,
                        Calendar cal)
                 throws SQLException
    Gets a Date value from the current row based on the name of the column desired using the Calendar specified. If the field is not a Date, or the record pointer is not positioned on a record, an exception may be thrown or the date may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    cal - a java.util.Calendar object
    Returns:
    value of the desired column as a Date value
    Throws:
    SQLException - thrown when unable to fetch the value, null values have no effect
    See Also:
    getDate(String)

    getTime

    public Time getTime(String columnName,
                        Calendar cal)
                 throws SQLException
    Gets a Time value from the current row based on the name of the column desired using the Calendar specified. If the field is not a Time field, or the record pointer is not positioned on a record, an exception may be thrown or the Time may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    cal - a java.util.Calendar object
    Returns:
    value of the desired column as a Time value
    Throws:
    SQLException - thrown when unable to fetch the value, null values have no effect
    See Also:
    getTime(String), getDate(String), (String, Calendar)

    getTime

    public Time getTime(String columnName)
                 throws SQLException
    Gets a Time value from the current row based on the name of the column desired using the default Calendar. If the field is not a Time field, or the record pointer is not positioned on a record, an exception may be thrown or the Time may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Time value
    Throws:
    SQLException - thrown when unable to fetch the value, null values have no effect
    See Also:
    getTime(String), getDate(String), (String, Calendar)

    getDouble

    public double getDouble(String columnName)
                     throws SQLException
    Gets a Double value from the current row based on the name of the column desired. If the field is not a Double number, or the record pointer is not positioned on a record, an exception will be thrown. or the date may be improperly translated.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Double value
    Throws:
    SQLException - thrown when unable to fetch the value or the value is not of type Double, null values have no effect

    getClob

    public Clob getClob(String columnName)
                 throws SQLException
    Gets a Clob (Character Large Object Block) object from the current row based on the name of the column desired. If the field is not a Clob, or the record pointer is not positioned on a record, an exception will be thrown. The interpretation of the Clob is dependent on the underlying SQL driver used. The object returned is a generic sql.java.Clob object.

    Parameters:
    columnName - name of the column to fetch the value from the current record
    Returns:
    value of the desired column as a Clob object
    Throws:
    SQLException - thrown when unable to fetch the value or the value is not of type CLOB, null values have no effect

    getColumnType

    public String getColumnType(String columnName)
                         throws SQLException
    Gets the database type of column in the selected drivers meta-data notation.

    Parameters:
    columnName - name of the column to investigate
    Returns:
    java type associated with the column type as a String
    Throws:
    SQLException - thrown if an error occurs, otherwise the value or null

    beforeFirst

    public void beforeFirst()
                     throws SQLException
    Moves the ResultSet cursor before the 1st record

    Throws:
    SQLException - thrown if a database access error occurs
    See Also:
    afterLast(), first(), last(), next(), nextRecord(), previous(), previousRecord()

    afterLast

    public void afterLast()
                   throws SQLException
    Moves the ResultSet cursor after the last record

    Throws:
    SQLException - throws a SQL exception if an error occurs while trying to reposition the result set
    See Also:
    beforeFirst(), first(), last(), next(), nextRecord(), previous(), previousRecord()

    next

    public boolean next()
                 throws SQLException
    Moves the record set pointer forward by one record. If there are no more records to advance to, nextRecord will return false, otherwise it will return true.

    Returns:
    boolean true if a record is found, false otherwise
    Throws:
    SQLException - thrown if a database access error occurs
    See Also:
    afterLast(), beforeFirst(), first(), last(), nextRecord(), previous(), previousRecord()

    nextRecord

    public void nextRecord()
                    throws SQLException
    Deprecated. as of 1.7.1, replaced by next() may be removed from future versions

    Method nextRecord will advance to the next record in the record set. If no additional records are found it will throw a SQLException.

    Throws:
    SQLException - thrown if no record is found
    See Also:
    afterLast(), beforeFirst(), first(), last(), next(), previous(), previousRecord()

    previous

    public boolean previous()
                     throws SQLException
    Method previous will move the record set pointer backward by one record. If there are no more records prior to the current record, nextRecord will return false, otherwise it will return true.

    Returns:
    boolean true if a record is found, false otherwise
    Throws:
    SQLException - if a database access error occurs
    See Also:
    afterLast(), beforeFirst(), first(), last(), next(), nextRecord(), previousRecord()

    previousRecord

    public void previousRecord()
                        throws SQLException
    Deprecated. as of 1.7.1, replaced by previous() may be removed from future versions

    Method previousRecord will move to the previous record in the record set. If no previous records are found it will throw a SQLException.

    Throws:
    SQLException - if a database access error occurs
    See Also:
    afterLast(), beforeFirst(), first(), last(), next(), nextRecord(), previous()

    first

    public void first()
               throws SQLException
    Moves the cursor position to the first record in the ResultSet. If the ResultSet is not established an exception will be thrown.

    Throws:
    SQLException - thrown if a database access error occurs
    See Also:
    afterLast(), beforeFirst(), last(), next(), nextRecord(), previous(), previousRecord()

    last

    public void last()
              throws SQLException
    Moves the cursor position to the last record in the ResultSet. If the ResultSet is not established an exception will be thrown.

    Throws:
    SQLException - thrown if a database access error occurs
    See Also:
    afterLast(), beforeFirst(), first(), next(), nextRecord(), previous(), previousRecord()

    getObject

    public Object getObject(int row,
                            int column)
                     throws SQLException
    Gets the column object specifed by integer position of the row and column. For example
    getObject(1,1)
    would get the first column in the first row in the established record set.

    If the record set did not previously exist, an exception is thrown.

    Parameters:
    row - the integer value of the record position (first record = 1)
    column - the integer value of the column position (first column = 1)
    Returns:
    Object or null
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    getObject(String), getObject(int,String), getObject(int)

    getObject

    public Object getObject(int row,
                            String columnName)
                     throws SQLException
    Gets the column object specifed by integer position of the row and column. For example
    getObject(1,1)
    would get the first column in the first row in the established record set.

    If the record set did not previously exist, an exception is thrown.

    Parameters:
    row - the integer value of the record position (first record = 1)
    columnName - name of the column to retreive
    Returns:
    Object or null
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    getObject(int,int), getObject(String), getObject(int)

    getObject

    public Object getObject(String columnName)
                     throws SQLException
    Gets the column object specifed by column name for the current row in the recordset. You must ensure that the cursor is pointed to a particular row otherwise an exception will be thrown.

    Parameters:
    columnName - name of the column to fetch
    Returns:
    Object or null
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    getObject(int,int), getObject(int,String), getObject(int)

    getObject

    public Object getObject(int i)
                     throws SQLException
    Gets the column object specifed by integer position of the column for the current row. You must ensure that the cursor is pointed to a particular row otherwise an exception will be thrown.

    Parameters:
    i - name of the column to fetch
    Returns:
    Object or null
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    getObject(int,int), getObject(String), getObject(int,String)

    getResultSet

    public ResultSet getResultSet()
    Gets the current java.sql.ResultSet

    Returns:
    ResultSet current ResultSet object or null if not set

    setConnection

    public void setConnection(Connection c)
                       throws SQLException
    Assigns the Connection c to this object to use for all operations

    Parameters:
    c - valid opened java.sql.Connection object
    Throws:
    SQLException - thrown if the connection is not open or valid

    getSize

    public int getSize()
    Gets the number of rows in the current ResultSet

    Returns:
    integer representing the number of rows in the ResultSet

    getColumnNames

    public String[] getColumnNames()
    Gets the column names from the current ResultSet and returns them as a string array

    Returns:
    String[] representing the names of the columns in the ResultSet or null

    getColumnCount

    public int getColumnCount()
    Gets the number of columns in the ResultSet

    Returns:
    int number of columns

    getColumnType

    public String getColumnType(int i)
    Gets the type of a particular column in the ResultSet by numeric position

    Parameters:
    i - position of the column in the result set
    Returns:
    String java variable type associated with the column

    isEmpty

    public boolean isEmpty()
    Determines of the ResultSet is empty or not

    Returns:
    boolean true if empty, otherwise false

    setArg

    public void setArg(String arg)
    Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)

    A convenience method for setting a single argument rather than having to establish an array or arguments.

    Parameters:
    arg - single argument as a String
    See Also:
    setArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList), getArguments(String), clearArgs()

    setArgs

    public void setArgs(String[] args)
    Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)

    Sets the arguments to use with the current SQL property

    Parameters:
    args - list of Arguments in a string array, all arguments are assumed to be of type String and anonymous
    See Also:
    setArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList), getArguments(String), clearArgs()

    setArguments

    public void setArguments(ArrayList nameList,
                             ArrayList typeList,
                             ArrayList valueList)
    Deprecated. As of release 1.5, replaced by setParameter(int,int,Object)

    Sets the arguments to use with the current SQL property

    Parameters:
    nameList - parameter name list
    typeList - parameter type list
    valueList - parameter value list
    See Also:
    setArgs(String[]), getArguments(String), clearArgs()

    close

    public void close()
    Closes the ResultSet thereby freeing the cursors. Note that this does not close the connection or reset any parameters.


    clearArgs

    public void clearArgs()
    Sets the current arguments and parameters to empty (null)


    setSql

    public void setSql(String sql)
    Sets the SQL to use for performing queries to populate the ResultSet with.

    Parameters:
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    See Also:
    getSql()

    getSql

    public String getSql()
    Gets the SQL currently set for this instance

    Returns:
    String representing the SQL code

    hasData

    public boolean hasData()
    Gets the state of the ResultSet returning true if the ResultSet contains data, otherwise false.

    Returns:
    true if the ResultSet currently contains data, false otherwise
    See Also:
    isEmpty()

    setCurrentRow

    public void setCurrentRow(int i)
                       throws SQLException
    Sets the cursor position to an absolute row in the ResultSet

    Parameters:
    i - row to point to
    Throws:
    SQLException - thrown if an access or database error occurs

    getCurrentRow

    public int getCurrentRow()
    Deprecated. As of release 1.5, replaced by getRow() may be removed from future versions

    Gets in the position of the cursor within the ResultSet

    Returns:
    int position of the cursor
    Since:
    1.0

    getRow

    public int getRow()
    Gets in the position of the cursor within the ResultSet.

    This is the same as (deprecated) {link #getCurrentRow()}. Essentially this is exactly like calling ResultSet.getRow().

    Returns:
    int position of the cursor
    Since:
    1.7.1

    getRowCount

    public int getRowCount()
    Gets the current number of rows in the ResultSet

    Returns:
    int number of rows in the ResultSet

    getColumnName

    public String getColumnName(int i)
    Gets the name of the column as indicated by the position of the column (i) within the ResultSet.

    Parameters:
    i - position of the column
    Returns:
    name of the column

    setData

    public void setData()
                 throws SQLException
    Deprecated. As of release 1.2, replaced by query()

    Establishes the result set by performing the query based on the given parameters.

    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    query(), query(String[]), query(String,String[]), query(java.sql.Connection,String,String[])

    setData

    public void setData(String[] args)
                 throws SQLException
    Deprecated. As of release 1.2, replaced by query(String[])

    Establishes the result set by performing the query based on the given parameters.

    Parameters:
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    query(), query(String[]), query(String,String[]), query(java.sql.Connection,String,String[])

    setData

    public void setData(String sql,
                        String[] args)
                 throws SQLException
    Deprecated. As of release 1.2, replaced by query(String,String[])

    Establishes the result set by performing the query based on the given parameters.

    Parameters:
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    query(), query(String[]), query(String,String[]), query(java.sql.Connection,String,String[])

    setData

    public void setData(Connection conn,
                        String sql,
                        String[] args)
                 throws SQLException
    Deprecated. As of release 1.2, replaced by query(java.sql.Connection,String,String[])

    Establishes the result set by performing the query based on the given parameters.

    Parameters:
    conn - Connection object representing an opened java.sql.Connection
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query()
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Establishes the data in the ResultSet based on the SQL property value and the arguments properties. This form assumes the SQL, Connection, and Argument properties have all been set already.

    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query(String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Establishes the data in the ResultSet based on the SQL property value and the arguments given. This form assumes the SQL, and Connection properties have all been set already.

    Parameters:
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query(String sql,
                      String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Establishes the data in the ResultSet based on the SQL given and the arguments given. This form assumes the Connection property has been set already.

    Parameters:
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query(Connection conn,
                      String sql,
                      String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Establishes the data in the ResultSet based on the SQL given and the arguments given. This form assumes sets the connection, SQL, and arguments properties at the time this method is used.

    Parameters:
    conn - Connection object representing an opened java.sql.Connection
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    args - String array representing the corresponding argument values
    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query(String sql)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Convenience version of query for use when no parameters are needed and a connection is already established from a previous query. This form accepts SQL as the only parameter and sets the corresponding property. The connection property and parameters are left unchanged.

    Parameters:
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    Throws:
    SQLException - thrown if an access or database error occurs

    query

    public void query(Connection conn,
                      String sql)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeQuery() may be removed from future versions

    Convenience version of query for use when no parameters are needed. This form accepts the connection, and SQL as parameters and sets the corresponding properties. The parameters must be set previously using setParameter or some similar construct or the SQL must not use any parameters.

    Parameters:
    conn - Connection object representing an opened java.sql.Connection
    sql - an SQL statement that may contain one or more '?' IN parameter placeholders
    Throws:
    SQLException - thrown if an access or database error occurs

    executeQuery

    public ResultSet executeQuery()
                           throws SQLException
    Establishes and returns the ResultSet based on the SQL property value and the established parameters using the established Connection property. This form assumes the SQL, Connection, and prameters have all been set already.

    Returns:
    a ResultSet object that contains the data produced by the query; never null
    Throws:
    SQLException - if a database access error occurs or the SQL statement does not return a ResultSet object

    executeUpdate

    public int executeUpdate()
                      throws SQLException
    Executes the SQL statement in this SQL property value, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement. This form assumes the SQL, Connection, and prameters have all been set already.

    Returns:
    either (1) the row count for INSERT, UPDATE, or DELETE statements or (2) 0 for SQL statements that return nothing
    Throws:
    SQLException - if a database access error occurs or the SQL statement does not return a ResultSet object

    update

    public int update()
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Updates the data that is the target of the SQL given and the arguments or object property. This form uses the connection, SQL, and arguments properties at the time this method is used.

    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs

    update

    public int update(String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Updates the data that is the target of the SQL given and the arguments or object property. This form uses the connection, and SQL properties at the time this method is used.  Any parameters must be set prior to making this call.

    Parameters:
    args - String array representing the corresponding argument values or null
    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs

    update

    public int update(String sql)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Convenience variant used when there are no arguments in the update and the connection has already been established. This form requires a SQL argument which sets the corresponding property. The Connection property and parameters are left unchanged.

    Parameters:
    sql - String representing the SQL to use
    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs

    update

    public int update(String sql,
                      String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Updates the data that is the target of the SQL given and the arguments or object property. This form uses the connection properties at the time this method is used.  The arguments must be passed to the method along with the SQL to use in the statement.  The arguments and statement establish the current corresponding properties for the SQLDataSet object when the method is invoked.

    Parameters:
    sql - String representing the SQL to use
    args - String array representing the corresponding argument values
    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs
    See Also:
    query(), query(String[]), query(String,String[]), query(java.sql.Connection,String,String[]), setConnProperty(java.sql.Connection), setConnection(java.sql.Connection), setSqlProperty(String), setSql(String), setArguments(java.util.ArrayList,java.util.ArrayList,java.util.ArrayList), setArgs(String[])

    update

    public int update(Connection conn,
                      String sql)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Convenience variant used when there are no arguments in the update. This form requires Connection and SQL arguments which sets the corresponding properties. Any prior argument properties are cleared.

    Parameters:
    conn - Connection object representing an opened java.sql.Connection
    sql - String representing the SQL to use
    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs

    update

    public int update(Connection conn,
                      String sql,
                      String[] args)
               throws SQLException
    Deprecated. as of 1.5, replaced by executeUpdate() may be removed from future versions

    Updates the data that is the target of the SQL given and the arguments or object property. This form requires all elements to be passed in the call.  The properties for the SQLDataSet object are set for the corresponding parameters at the time of the call.

    Parameters:
    conn - Connection object representing an opened java.sql.Connection
    sql - String representing the SQL to use
    args - String array representing the corresponding argument values
    Returns:
    number of rows processed
    Throws:
    SQLException - thrown if an access or database error occurs

    getSqlProperty

    public String getSqlProperty()
    Gets the currently established SQL property

    Returns:
    String SQL code

    setSqlProperty

    public void setSqlProperty(String value)
    Sets the current SQL code property used in a query

    Parameters:
    value - valid SQL code

    setParameter

    public void setParameter(int parameterIndex,
                             int sqlType,
                             Object x)
                      throws SQLException
    Sets a parameter for use in the subsequent query or update call by evaluating the type and object value passed in.

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

    getParameterMetaData

    public final ParameterMetaData getParameterMetaData()
                                                 throws SQLException
    Retrieves the number, types and properties of this PreparedStatement object's parameters.

    Returns:
    a ParameterMetaData object that contains information about the number, types and properties of this PreparedStatement object's parameters
    Throws:
    SQLException - if a database access error occurs

    getConnProperty

    public Connection getConnProperty()
    Gets the current database connection object

    Returns:
    java.sql.Connection object

    setRowCount

    protected void setRowCount()
    Sets the current row count property to the size of the current record set. Normally this is set when needed and is not usually manipulated directly. When using this method on large record sets, the amount of RAM consumed will be high, therefore, by default, it is not set when the record set is established.


    setConnProperty

    public void setConnProperty(Connection value)
                         throws SQLException
    Sets the current database connection property. Does not establish a session with the database, the connection must aready be open.

    Parameters:
    value - java.sql.Connection object
    Throws:
    SQLException

    addPropertyChangeListener

    public void addPropertyChangeListener(PropertyChangeListener listener)
    Creates a property change listener

    Parameters:
    listener - PropertyChangeListener object

    removePropertyChangeListener

    public void removePropertyChangeListener(PropertyChangeListener listener)
    Removes a set property

    Parameters:
    listener - PropertyChangeListener object

    setArray

    public void setArray(int parameterIndex,
                         Array x)
                  throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setAsciiStream

    public void setAsciiStream(int parameterIndex,
                               InputStream x,
                               int length)
                        throws SQLException
    Sets the designated parameter to the given input stream, which will have the specified number of bytes. 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. Data will be read from the stream as needed until end-of-file is reached. 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.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the Java input stream that contains the ASCII parameter value
    length - the number of bytes in the stream
    Throws:
    SQLException - if a database access error occurs

    setBigDecimal

    public void setBigDecimal(int parameterIndex,
                              BigDecimal x)
                       throws SQLException
    Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.

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

    setBinaryStream

    public void setBinaryStream(int parameterIndex,
                                InputStream x,
                                int length)
                         throws SQLException
    Sets the designated parameter to the given input stream, which will have the specified number of bytes. 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 object. The data will be read from the stream as needed until end-of-file is reached. Data will be read from the stream as needed until end-of-file is reached. 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.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the Java input stream that contains the ASCII parameter value
    length - the number of bytes in the stream
    Throws:
    SQLException - if a database access error occurs

    setBlob

    public void setBlob(int parameterIndex,
                        Blob x)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Blob value. The driver converts this to an SQL BLOB value when it sends it to the database.

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

    setClob

    public void setClob(int parameterIndex,
                        Clob x)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Clob value. The driver converts this to an SQL CLOB value when it sends it to the database.

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

    setBoolean

    public void setBoolean(int parameterIndex,
                           boolean x)
                    throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setByte

    public void setByte(int parameterIndex,
                        byte x)
                 throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setBytes

    public void setBytes(int parameterIndex,
                         byte[] x)
                  throws SQLException
    Sets the designated parameter to the given Java array of bytes value. 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:
    SQLException - if a database access error occurs

    setCharacterStream

    public void setCharacterStream(int parameterIndex,
                                   Reader reader,
                                   int length)
                            throws SQLException
    Sets the designated parameter to the given Reader object, which is the given number of characters long. When a very large UNICODE value is input to a LONGVARCHAR parameter, it may be more practical to send it via a java.io.Reader object. The data will be read from the stream as needed until end-of-file is reached. 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.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    reader - the java.io.Reader object that contains the Unicode data
    length - the number of characters in the stream
    Throws:
    SQLException - if a database access error occurs

    setNull

    public void setNull(int parameterIndex,
                        int sqlType)
                 throws 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:
    SQLException - if a database access error occurs

    setObject

    public void setObject(int parameterIndex,
                          Object x)
                   throws SQLException
    Sets the value of the designated parameter using the given object. The second parameter must be of type Object; therefore, the java.lang equivalent objects should be used for built-in types. The JDBC specification specifies a standard mapping from Java Object types to SQL types. The given argument will be converted to the corresponding SQL type before being sent to the database. Note that this method may be used to pass datatabase- specific abstract data types, by using a driver-specific Java type. If the object is of a class implementing the interface SQLData, the JDBC driver should call the method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, Struct, or Array, the driver should pass it to the database as a value of the corresponding SQL type. This method throws an exception if there is an ambiguity, for example, if the object is of a class implementing more than one of the interfaces named above.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the object containing the input parameter value
    Throws:
    SQLException - if a database access error occurs or the type of the given object is ambiguous

    setRef

    public void setRef(int parameterIndex,
                       Ref x)
                throws SQLException
    Sets the designated parameter to the given REF() value. The driver converts this to an SQL REF value when it sends it to the database.

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

    setShort

    public void setShort(int parameterIndex,
                         short x)
                  throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setTime

    public void setTime(int parameterIndex,
                        Time x)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Time value 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:
    SQLException - if a database access error occurs

    setTime

    public void setTime(int parameterIndex,
                        Time x,
                        Calendar cal)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Time value, using the given Calendar object. The driver uses the Calendar object to construct an SQL TIME value, which the driver then sends to the database. With a Calendar object, the driver can calculate the time taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the parameter value
    cal - the Calendar object the driver will use to construct the time
    Throws:
    SQLException - if a database access error occurs

    setURL

    public void setURL(int parameterIndex,
                       URL x)
                throws SQLException
    Sets the designated parameter to the given java.net.URL value. The driver converts this to an SQL DATALINK value when it sends it to the database.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the java.net.URL object to be set
    Throws:
    SQLException - if a database access error occurs

    setDate

    public void setDate(int parameterIndex,
                        Date x)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Date 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:
    SQLException - if a database access error occurs

    setDate

    public void setDate(int parameterIndex,
                        Date x,
                        Calendar cal)
                 throws SQLException
    Sets the designated parameter to the given java.sql.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.

    Parameters:
    parameterIndex - the first parameter is 1, the second is 2, ...
    x - the parameter value
    cal - the Calendar object the driver will use to construct the time
    Throws:
    SQLException - if a database access error occurs

    setInt

    public void setInt(int parameterIndex,
                       int x)
                throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setString

    public void setString(int parameterIndex,
                          String x)
                   throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setDouble

    public void setDouble(int parameterIndex,
                          double x)
                   throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setFloat

    public void setFloat(int parameterIndex,
                         float x)
                  throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setLong

    public void setLong(int parameterIndex,
                        long x)
                 throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setTimestamp

    public void setTimestamp(int parameterIndex,
                             Timestamp x)
                      throws SQLException
    Sets the designated parameter to the given 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:
    SQLException - if a database access error occurs

    setAutoCommit

    public void setAutoCommit(boolean state)
    Turns automatic comitting on or off. When on, an implicit commit is performed at the end of each transaction. When off, an explicit commit must be performed either through the driver or through the doCommit() method. If using the later, automatic rollback can also be employed whereby the transactions can be coded with a commit statement that can be globally invoked by turning commit processing on or off. Turning off automatic commit processing does not turn off commit processing independently. However, turning on automatic commit processing does implicitly turn on committing.

    Parameters:
    state - set to ON to enable or OFF to disable
    See Also:
    setCommitting(boolean), doCommit(), doRollback(java.sql.Savepoint)

    setCommitting

    public void setCommitting(boolean state)
    Turns commit processing on or off. When on, calls to doCommit() perform the commit as expected. When off, calls to doCommit() have no effect. If automatic rollback is also enabled, when committing is off, the transaction is rolledback when a doCommit() command is encountered. When automatic rollback is off and committing is off no action is taken with the transaction set.

    Closing the connection or dataset will invoke a commit regardless of the commit settings. It is also possible to override these calls by manipulating the Connection object directly. Turning off committing also disables automatic commit processing, therefore there is no need to call setAutoCommit(boolean) followed by this method. Simply calling setCommitting with false will turn off both. Conversely, turning on Committing will not automatically turn on automatic commit processing.

    Parameters:
    state - set to ON to enable or OFF to disable
    See Also:
    setAutoCommit(boolean), doCommit(), doRollback(java.sql.Savepoint)

    setAutoRollback

    public void setAutoRollback(boolean state)
    Turns automatic rollback functionality on or off. When a doCommit() action would normally be processed, if automatic rollback is enabled, the transaction is rolled back instead of committed. If automatic rollback is enabled and committing is also enabled, the transaction is committed. If automatic rollback is enabled and committing is not, the transaction is rolled back when a doCommit() is encountered.

    Parameters:
    state - set to ON to enable or OFF to disable
    See Also:
    doCommit(), doRollback(java.sql.Savepoint)

    doCommit

    public boolean doCommit()
    Performs a commit action within the database connection. The result if the operation is returned as true or false. If the connection is closed or invalid the method returns false.

    Returns:
    true if the operation was successful or false otherwise
    See Also:
    setAutoRollback(boolean), setAutoCommit(boolean), setCommitting(boolean)

    doRollback

    public boolean doRollback(Savepoint sp)
    Performs a rollback action within the database connection. The result if the operation is returned as true or false. If the connection is closed or invalid the method returns false. This operates independently from the setAutoRollback(boolean) functionality and will invoke the rollback regardless of the automatic rollback or automatic commit state. If autocommit is enabled (the default), then this has no effect.

    Parameters:
    sp - savepoint to rollback to
    Returns:
    true if the rollback succeeded otherwise false
    See Also:
    setAutoRollback(boolean), setSavePoint()

    doRollback

    public boolean doRollback()
    Performs a rollback action within the database connection. The result if the operation is returned as true or false. If the connection is closed or invalid the method returns false. This operates independently from the setAutoRollback(boolean) functionality and will invoke the rollback regardless of the automatic rollback or automatic commit state.

    Returns:
    true if the rollback succeeded otherwise false
    See Also:
    setAutoRollback(boolean)

    getAutoCommit

    public boolean getAutoCommit()
    Returns the current state of automatic commit processing.

    Returns:
    true if the autocommit functionality is enabled, otherwise false
    See Also:
    setAutoCommit(boolean)

    getCommitting

    public boolean getCommitting()
    Returns the current state of commit processing. Commit processing can be turned on or off independently of automatic commit processing. When enabling automatic commit processing, the commit state is assumed to be true or enabled.

    Returns:
    true if the commit functionality is enabled, otherwise false
    See Also:
    setAutoCommit(boolean)

    getAutoRollback

    public boolean getAutoRollback()
    Returns the current state of automatic rollback functionality.

    Returns:
    true if the automatic rollback functionality is enabled, otherwise false
    See Also:
    setAutoRollback(boolean)

    setSavePoint

    public Savepoint setSavePoint()
    Sets an un-named savepoint in the current transaction. This only applies when the automatic commit processing is turned off. When automatic committing is turned on, this will have no effect because any rollback would have no effect.

    Returns:
    unnamed savepoint or null if the automatic commit processing is enabled
    See Also:
    setAutoCommit(boolean)

    setSavePoint

    public Savepoint setSavePoint(String s)
    Sets an named savepoint in the current transaction. This only applies when the automatic commit processing is turned off. When automatic committing is turned on, this will have no effect because any rollback would have no effect.

    Parameters:
    s - the name given to the save point
    Returns:
    unnamed savepoint or null if the automatic commit processing is enabled
    See Also:
    setAutoCommit(boolean)

    releaseSavepoint

    public void releaseSavepoint(Savepoint sp)
    Releases a given savepoint. This only applies when automatic commit processing is turned off. Issuing this command when on, or using an invalid savepoint has no effect and does not throw an error.

    Parameters:
    sp - the savepoint to release

    MDi JLib
    1.7.4

    Copyright©2001-2007 MicroDeveloper, Inc. All Rights Reserved.