FileDocCategorySizeDatePackage
ConnectionPerClient.javaAPI DocExample3230Thu Apr 05 01:53:56 BST 2001None

ConnectionHolder

public class ConnectionHolder extends Object implements HttpSessionBindingListener

Fields Summary
private Connection
con
Constructors Summary
public ConnectionHolder(Connection con)


     
    // Save the Connection
    this.con = con;
    try {
      con.setAutoCommit(false);  // transactions can extend between web pages!
    }
    catch(SQLException e) {
      // Perform error handling
    }
  
Methods Summary
public java.sql.ConnectiongetConnection()

    return con;  // return the cargo
  
public voidvalueBound(javax.servlet.http.HttpSessionBindingEvent event)

    // Do nothing when added to a Session
  
public voidvalueUnbound(javax.servlet.http.HttpSessionBindingEvent event)

    // Roll back changes when removed from a Session
    // (or when the Session expires)
    try {
      if (con != null) {
        con.rollback();  // abandon any uncomitted data
        con.close();
      }
    }
    catch (SQLException e) {
      // Report it
    }