Java Reference
In-Depth Information
public static void displayTable() throws SQLException
{
String select = "SELECT * FROM Accounts";
results = statement.executeQuery(select);
System.out.println();
while (results.next())
{
System.out.println("Account no. "
+ results.getInt(1));
System.out.println("Account holder: "
+ results.getString(3)
+ " " + results.getString(2));
System.out.printf("Balance: %.2f %n%n",
results.getFloat(4));
}
}
}
The output from this program is shown in Fig. 7.2 .
Fig. 7.2 Output from program JDBCChange
Search WWH ::




Custom Search