Java Reference
In-Depth Information
{
//Step 1…
connection = DriverManager.getConnection(
"jdbc:odbc:Finances","","");
}
//For any of a number of reasons, it may not be
//possible to establish a connection…
catch(SQLException sqlEx)
{
System.out.println(
"* Cannot connect to database! *");
System.exit(1);
}
try
{
//Step 2…
statement = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String select = "SELECT * FROM Accounts";
System.out.println(
"\nInitial contents of table:\n");
//Steps 3 and 4…
displayTable();
//Start of step 5…
//First the update…
results.absolute(2);
//(Move to row 2 of ResultSet . )
results.updateFloat("balance", 42.55f);
results.updateRow();
//Now the insertion…
results.moveToInsertRow();
results.updateInt("acctNum", 999999);
results.updateString("surname", "Harrison");
results.updateString("fi rstNames",
"Christine Dawn");
results.updateFloat("balance", 2500f);
results.insertRow();
Search WWH ::




Custom Search