FileDocCategorySizeDatePackage
ConnectionPerClient.javaAPI DocExample3044Tue Jan 25 10:45:14 GMT 2000None

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
    }