com.youyounet.db
Class DBContext

java.lang.Object
  |
  +--com.youyounet.db.DBContext

public class DBContext
extends java.lang.Object

A DBContext Object is usually used as a database transaction context within an application. It could also be subclassed to create a custom context, for example, a user session context in a web application, and store not only the database information, but also the user session information in the context.


Field Summary
protected  java.sql.Connection con
           
protected  boolean isClosed
           
protected static java.util.logging.Logger log
           
 
Constructor Summary
DBContext()
          public constructor
 
Method Summary
 void abort()
          abort the transaction if the context is not closed and the connection is not closed.
 void commit()
          commit the transaction if the context is not closed and the connection is not closed.
 java.sql.Connection getConnection()
          get the DB connection object from the context
 boolean isClosed()
          check if the context is closed
 void reset()
          close the DB connection associated with this context if it's open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static java.util.logging.Logger log

con

protected java.sql.Connection con

isClosed

protected boolean isClosed
Constructor Detail

DBContext

public DBContext()
public constructor

Method Detail

isClosed

public boolean isClosed()
check if the context is closed


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
get the DB connection object from the context

java.sql.SQLException

abort

public void abort()
           throws java.sql.SQLException
abort the transaction if the context is not closed and the connection is not closed. Otherwise an IllegalStateException will be thrown

java.sql.SQLException

commit

public void commit()
            throws java.sql.SQLException
commit the transaction if the context is not closed and the connection is not closed. Otherwise an IllegalStateException will be thrown

java.sql.SQLException

reset

public void reset()
close the DB connection associated with this context if it's open