FileDocCategorySizeDatePackage
SingleThreadConnection.javaAPI DocExample1409Thu Apr 05 21:23:48 BST 2001None

SingleThreadConnection

public class SingleThreadConnection extends HttpServlet implements SingleThreadModel

Fields Summary
Connection
con
Constructors Summary
Methods Summary
public voiddestroy()

    if (con != null) {
      try { con.close(); } catch (SQLException ignored) { }
    }
  
public voiddoGet(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.ConnectionestablishConnection()

    // Not implemented.  See Chapter 9.
  
public voidinit()

  // 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());
    }