Class ResourceAccessorJ2SE

  extended by de.mathema.pride.AbstractResourceAccessor
      extended by de.mathema.pride.ResourceAccessorJ2SE
All Implemented Interfaces:
ResourceAccessor, SQLFormatter

public class ResourceAccessorJ2SE
extends AbstractResourceAccessor

Simple ResourceAccessor for J2SE environments. This implementation stores database connections in a ThreadLocal object, which garuantees fast connection access and multi-threading safety. However, the connection is kept until the accessor is invoked with a different database name. It is therefore recommended to work with multiple accessors if you need to swith rapidly between multiple databases.

Jan Lessner

Nested Class Summary
Nested classes/interfaces inherited from interface de.mathema.pride.ResourceAccessor
ResourceAccessor.AutoKeyMode, ResourceAccessor.Config, ResourceAccessor.DBType
Field Summary
static java.lang.String REVISION_ID
Fields inherited from class de.mathema.pride.AbstractResourceAccessor
autoKeyMode, dateFormat, dbPassword, dbSystime, dbType, dbUser, props, timeFormat
Fields inherited from interface de.mathema.pride.ResourceAccessor
Constructor Summary
ResourceAccessorJ2SE(java.util.Properties props)
          Constructs a new ResourceAccessor for use in a J2SE environment
Method Summary
 java.sql.Connection getConnection(java.lang.String db)
          Return a JDBC database connection.
 void releaseConnection()
          Close the current thread's connection.
 void releaseConnection(java.sql.Connection con)
          Does nothing at all
Methods inherited from class de.mathema.pride.AbstractResourceAccessor
castJavaUtilDate, commonDateFormat, escape, escapeBackslahes, escapeQuotes, formatBoolean, formatDate, formatEnum, formatOperator, formatPreparedValue, formatTime, formatValue, getAutoFields, getAutoFieldVals, getDBType, getSystime, getTableName, getURL, getUserName, isLogging, setAutoCommit, setLogging, sqlLog, sqlLogError, standardOperator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final java.lang.String REVISION_ID
See Also:
Constant Field Values
Constructor Detail


public ResourceAccessorJ2SE(java.util.Properties props)
                     throws java.lang.Exception
Constructs a new ResourceAccessor for use in a J2SE environment

props - The configuration for the resource accessor. See interface ResourceAccessor.Config for available parameters. The property ResourceAccessor.Config.DRIVER is mandatory
Method Detail


public java.sql.Connection getConnection(java.lang.String db)
                                  throws java.sql.SQLException
Return a JDBC database connection. There is one unique connection returned per thread and kept allocated until this function is invoked with a different database name or function releaseConnection() is explicitely called. The connection is optained from DriverManager.getConnection() passing either user and password when specified in the constructor by properties ResourceAccessor.Config.USER and ResourceAccessor.Config.USER or otherwise passing the complete constructor Properties list as is.



public void releaseConnection()
                       throws java.sql.SQLException
Close the current thread's connection. It is recommended to explicitely release connections if the associated thread is about to terminate or sleep for a long time. JDBC's built-in connection garbage collection is either not working at all or is not this agile as it may be required.



public void releaseConnection(java.sql.Connection con)
                       throws java.sql.SQLException
Does nothing at all