Java Reference
In-Depth Information
L ISTING 7.4 Continued
Statement statement = con.createStatement();
// Use the created statement to UPDATE DATA in
// the database tables.
// Update the Quantity of “The Last Emperor”
statement.executeUpdate(“UPDATE Titles “ +
“SET quantity = 5 “ +
“WHERE title_name = 'The Last Emperor'”);
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
try {
if ( con != null ) {
// Close the connection no matter what
con.close();
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
}
}
public static void main(String[] args) {
UpdateDataApp updateDataApp = new UpdateDataApp();
updateDataApp.updateData();
}
}
Search WWH ::




Custom Search