FileDocCategorySizeDatePackage
ConnectionManager.javaAPI DocExample797Mon Nov 24 09:37:40 GMT 2003com.oreilly.patterns.chapter10

ConnectionManager

public final class ConnectionManager extends Object

Fields Summary
private static final ThreadLocal
currentConnection
Constructors Summary
Methods Summary
public static java.sql.ConnectiongetConnection()

        return (Connection)currentConnection.get();
    
static java.sql.ConnectionsetConnection(java.sql.Connection connection)

     
          
        Connection priorConnection = (Connection)currentConnection.get();
        currentConnection.set( connection );
        // We return the prior connection, if any, to give the application
        // the opportunity to deal with it, if so desired. It's important
        // that all database connections be properly closed.
        return priorConnection;