JavaXT

Recordset Class

Used to query and update records in a database.

Constructors

public Recordset( )

Methods

addNew( ) returns void
Used to prepare the driver to insert new records to the database. Used in conjunction with the update method.
close( ) returns void
Closes the Recordset freeing up database and jdbc resources.
commit( ) returns void
Used to explicitely commit an sql statement. May be useful for bulk update and update statements, depending on the underlying DBMS.
getBatchSize( ) returns int
getConnection( ) returns javaxt.sql.Connection
Returns the JDBC Connection used to create/open the recordset.
getDatabase( ) returns javaxt.sql.Database
Returns connection information to the database.
getField( String FieldName ) returns javaxt.sql.Field
Returns a specific field in the array of fields. Returns null if the field name is not found.
getField( int i ) returns javaxt.sql.Field
Returns a specific field in the array of fields. Returns null if the index is out of range.
getFields( ) returns javaxt.sql.Field[]
Used to retrieve the an array of fields in the current record.
getGeneratedKey( ) returns javaxt.sql.Value
Returns an auto-generated key created after inserting a record in the database. If this Statement object did not generate any keys, an empty Value object is returned.
getRecordCount( ) returns int
Used to retrieve the total record count. Note that this method may be slow.
getValue( String FieldName ) returns javaxt.sql.Value
Returns the Value associated with a given field. Note the if the field doesn't exist in the result set, the method will return still return a Value. You can use the isNull() method on the Value to determine whether the value is null.
getValue( int i ) returns javaxt.sql.Value
Returns the Value associated with a given field. Note the if the field doesn't exist in the result set, the method will return still return a Value. You can use the isNull() method on the Value to determine whether the value is null.
hasNext( ) returns boolean
Returns true if the recordset has more records.
isDirty( ) returns boolean
Returns true if any of the fields have been modified. You can find which field has been modified using the Field.isDirty() method. Example:
    if (rs.isDirty()){
        for (javaxt.sql.Field field : rs.getFields()){
            if (field.isDirty()){
                String val = field.getValue().toString();
                System.out.println(field.getName() + ": " + val);
            }
        }
    }
   
isOpen( ) returns boolean
Returns true if the recordset is open. This method is only supported on Java 1.6 or higher. Otherwise, the method will return false.
isReadOnly( ) returns boolean
Returns true if records are read-only.
move( int numRecords ) returns void
Moves the cursor to n-number of rows in the database. Typically this method is called before iterating through a recordset.
moveNext( ) returns boolean
Move the cursor to the next record in the recordset.
open( String sql, javaxt.sql.Connection conn ) returns java.sql.ResultSet
Used to execute a query and access records in the database. Records fetched using this method cannot be updated or deleted and new records cannot be inserted into the database.
sqlSQL Query. Example: "SELECT * FROM EMPLOYEE"
connAn active connection to the database.
open( String sqlString, javaxt.sql.Connection Connection, boolean ReadOnly ) returns java.sql.ResultSet
Used to execute a query and access records in the database.
sqlStringSQL Query. Example: "SELECT * FROM EMPLOYEE"
ConnectionAn active connection to the database.
ReadOnlySet whether the records are read-only. If true, records fetched using this method cannot be updated or deleted and new records cannot be inserted into the database. If false, records can be updated or deleted and new records can be inserted into the database.
setBatchSize( int batchSize ) returns void
Used to set the number of records to insert in a batch. By default, this value is set to 1 so that records are inserted one at a time. By setting a larger number, more records are inserted at a time which can significantly improve performance.
setFetchSize( int fetchSize ) returns void
This method changes the block fetch size for server cursors. This may help avoid out of memory exceptions when retrieving a large number of records from the database. Set this method BEFORE opening the recordset.
setValue( String FieldName, javaxt.sql.Value FieldValue ) returns void
setValue( String FieldName, Object FieldValue ) returns void
Set Value with an Object value.
setValue( String FieldName, boolean FieldValue ) returns void
Set Value with a Boolean value
setValue( String FieldName, long FieldValue ) returns void
Set Value with a Long value
setValue( String FieldName, int FieldValue ) returns void
Set Value with an Integer value
setValue( String FieldName, double FieldValue ) returns void
Set Value with a Double value
setValue( String FieldName, short FieldValue ) returns void
Set Value with a Short value
update( ) returns void
Used to add or update a record in a table. Note that inserts can be batched using the setBatch() method to improve performance. When performing batch inserts, the update statements are queued and executed only after the batch size is reached.