Java Reference
In-Depth Information
catch(SQLException sqlEx)
{
System.out.println(
"* Cannot connect to database! *");
System.exit(1);
}
try
{
statement = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
results = statement.executeQuery(
"SELECT * FROM Accounts");
}
catch(SQLException sqlEx)
{
System.out.println(
"* Cannot execute query! *");
sqlEx.printStackTrace();
System.exit(1);
}
try
{
while (results.next())
//Iterate through the rows in the forward
//direction, displaying the contents of each
//row (as in the original program)…
showRow();
}
catch(SQLException sqlEx)
{
System.out.println(
"* Error retrieving data! *");
sqlEx.printStackTrace();
System.exit(1);
}
try
{
//Cursor for ResultSet is now positioned
//just after last row, so we can make use
//of method previous to access the data…
Search WWH ::




Custom Search