Methods Summary |
---|
public void | destroy()
if (con != null) {
try { con.close(); } catch (SQLException ignored) { }
}
|
public void | doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
try {
// Use the connection uniquely assigned to this instance
Statement stmt = con.createStatement();
// Update the database any number of ways
// Commit the transaction
con.commit();
}
catch (SQLException e) {
try { con.rollback(); } catch (SQLException ignored) { }
}
|
private java.sql.Connection | establishConnection()
// Not implemented. See Chapter 9.
|
public void | init() // database connection, one per pooled instance
// Establish the connection for this instance
try {
con = establishConnection();
con.setAutoCommit(false);
}
catch (SQLException e) {
throw new ServletException(e.getMessage());
}
|