Java Reference
In-Depth Information
Table 4-4: ResultSet Update Methods
Data Type
Method
java.io.InputStream
updateAsciiStream(String columnName, InputStream x, int length)
java.io.InputStream
updateUnicodeStream(String columnName, InputStream x, int length)
java.io.InputStream
updateBinaryStream(String columnName, InputStream x, int length)
java.sql.Date
updateDate(String columnName, Date x)
java.sql.Time
updateTime(String columnName, Time x)
java.sql.Timestamp
updateTimestamp(String columnName, Timestamp x)
long
updateLong(String columnName, long x)
Object
updateObject(String columnName, Object x)
Object
updateObject(String columnName, Object x, int scale)
short
updateShort(String columnName, short x)
String
updateString(String columnName, String x)
NULL
updateNull(String columnName)
Note that after updating a column value in the ResultSet, you must call the
ResultSet's updateRow() method to make a permanent change in the database
before moving the cursor, since changes made using the update methods do not take
effect until updateRow() is called.
If you move the cursor to another row before calling updateRow(), the
updates will be lost, and the row will revert to its previous column
values.
Caution
You can specifically cancel updates any time before calling updateRow() by calling
the cancelRowUpdates() method. Once you have called updateRow(), however, the
cancelRowUpdates() method no longer works.
Inserting a New Row
In addition to supporting updates, an UpdatableResultSet supports the insertion and
deletion of entire rows. The ResultSet object has a row called the insert row , which is,
in effect, a dedicated row buffer in which you can build a new row.
The new row is created in a manner very similar to the row updates discussed earlier.
Simply follow these steps:
1. Move the cursor to the insert row, which is done by calling the method moveToInsertRow().
Search WWH ::




Custom Search