Java Reference
In-Depth Information
try {
rs.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
This method could be called passing a string value containing a recipe number.
Suppose that the recipe number
"13-1"
was passed to this method; the following out-
put would be the result:
Successfully connected
13-1: Connecting to a Database - DriverManager and
DataSource Implementations
13-2: Querying a Database and Retrieving Results
- Obtaining and Using Data from a DBMS
13-3: Handling SQL Exceptions - Using SQLException
Updating rowDriverManager and DataSource Implementations
13-1: Connecting to a Database - DriverManager and
DataSource Implementations - More to come
13-2: Querying a Database and Retrieving Results
- Obtaining and Using Data from a DBMS
13-3: Handling SQL Exceptions - Using SQLException
How It Works
Sometimes you need to update data as you are parsing it. Usually this technique in-
volves testing the values that are being returned from the database and updating them
after comparison with another value. The easiest way to do this is to make the
Res-
ultSet
object updatable by passing the
ResultSet.CONCUR_UPDATABLE
con-
stant to the
Connection
object's
createStatement()
or
prepareState-
ment()
method. Doing so causes the
Statement
or
PreparedStatement
to
produce an updatable
ResultSet
.