com.j256.ormlite.support
Class BaseConnectionSource

java.lang.Object
  extended by com.j256.ormlite.support.BaseConnectionSource
All Implemented Interfaces:
ConnectionSource

public abstract class BaseConnectionSource
extends Object
implements ConnectionSource

Connection source base class which provides the save/clear mechanism using a thread local.

Author:
graywatson

Field Summary
protected  boolean usedSpecialConnection
           
 
Constructor Summary
BaseConnectionSource()
           
 
Method Summary
protected  boolean clearSpecial(DatabaseConnection connection, Logger logger)
          Clear the connection that was previously saved.
protected  DatabaseConnection getSavedConnection()
          Returns the connection that has been saved or null if none.
 DatabaseConnection getSpecialConnection()
          Return the currently saved connection or null if none.
protected  boolean isSavedConnection(DatabaseConnection connection)
          Return true if the connection being released is the one that has been saved.
protected  boolean saveSpecial(DatabaseConnection connection)
          Save this connection as our special connection to be returned by the getSavedConnection() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.j256.ormlite.support.ConnectionSource
clearSpecialConnection, close, getDatabaseType, getReadOnlyConnection, getReadWriteConnection, isOpen, releaseConnection, saveSpecialConnection
 

Field Detail

usedSpecialConnection

protected boolean usedSpecialConnection
Constructor Detail

BaseConnectionSource

public BaseConnectionSource()
Method Detail

getSpecialConnection

public DatabaseConnection getSpecialConnection()
Description copied from interface: ConnectionSource
Return the currently saved connection or null if none.

Specified by:
getSpecialConnection in interface ConnectionSource

getSavedConnection

protected DatabaseConnection getSavedConnection()
Returns the connection that has been saved or null if none.


isSavedConnection

protected boolean isSavedConnection(DatabaseConnection connection)
Return true if the connection being released is the one that has been saved.


saveSpecial

protected boolean saveSpecial(DatabaseConnection connection)
                       throws SQLException
Save this connection as our special connection to be returned by the getSavedConnection() method.

Returns:
True if the connection was saved or false if it was already saved.
Throws:
SQLException

clearSpecial

protected boolean clearSpecial(DatabaseConnection connection,
                               Logger logger)
Clear the connection that was previously saved.

Returns:
True if the connection argument had been saved.


This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.