Java Reference
In-Depth Information
L ISTING 7.11
Continued
// Iterate over the ResultSet
while ( rs.next() ) {
out.println(“<tr>”);
// get the id, which is an int
out.println(“<td>” + rs.getInt(“title_id”) + “</td>”);
// get the name, which is a String
out.println(“<td>” + rs.getString(“title_name”) + “</td>”);
7
// get the rating, which is a String
out.println(“<td>” + rs.getString(“rating”) + “</td>”);
// get the price, which is a Float
out.println(“<td>” + rs.getFloat(“price”) + “</td>”);
// get the Quantity, which is a Integer
out.println(“<td>” + rs.getInt(“quantity”) + “</td>”);
// get the Type, which is a Integer
out.println(“<td>” + rs.getInt(“type_id”) + “</td>”);
// get the Category, which is a Integer
out.println(“<td>” + rs.getInt(“category_id”) + “</td>”);
out.println(“</tr>”);
}
// Close the ResultSet
rs.close();
out.println(“</table>”);
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
catch (Exception e) {
System.err.println(e.getMessage());
}
finally {
// Release the connection
 
Search WWH ::




Custom Search