de.mathema.pride
Class ResourceAccessorJ2EE

java.lang.Object
  extended by de.mathema.pride.AbstractResourceAccessor
      extended by de.mathema.pride.ResourceAccessorJ2EE
All Implemented Interfaces:
ResourceAccessor, SQLFormatter
Direct Known Subclasses:
ResourceAccessorWeb

public class ResourceAccessorJ2EE
extends AbstractResourceAccessor

Simple ResourceAccessor for J2EE environments. This implementation fetches database connections from a DataSource and assumes that connections are pooled by the application server.

Author:
Jan Lessner

Nested Class Summary
 
Nested classes/interfaces inherited from interface de.mathema.pride.ResourceAccessor
ResourceAccessor.AutoKeyMode, ResourceAccessor.Config, ResourceAccessor.DBType
 
Field Summary
protected  javax.sql.DataSource globalDataSource
           
protected static java.lang.String LOCAL_JNDI_CONTEXT
           
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
SYSTIME_DEFAULT
 
Constructor Summary
ResourceAccessorJ2EE(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()
          Does nothing at all, we rely on the connection handling of the application server
 void releaseConnection(java.sql.Connection con)
          Calls the connection's close function which is supposed to cause a fast logical releasement.
 
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

LOCAL_JNDI_CONTEXT

protected static final java.lang.String LOCAL_JNDI_CONTEXT
See Also:
Constant Field Values

globalDataSource

protected javax.sql.DataSource globalDataSource

REVISION_ID

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

ResourceAccessorJ2EE

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

Parameters:
props - The configuration for the resource accessor. See interface ResourceAccessor.Config for available parameters.
Throws:
java.lang.Exception
Method Detail

getConnection

public java.sql.Connection getConnection(java.lang.String db)
                                  throws java.sql.SQLException,
                                         javax.naming.NamingException
Return a JDBC database connection. The passed database name is interpreted as a JNDI name used to lookup a DataSource to get a connection from. If the JNDI name starts with java:comp/env, the lookup is performed in the current EJBs local environment with every single call. Otherwise the lookup is performed only once and the DataSource is stored as a member variable for reuse in subsequent calls of getConnection. If the application performs many simple database interactions, it is strongly recommended to use global JNDI names for the sake of performance.

Throws:
java.sql.SQLException
javax.naming.NamingException

releaseConnection

public void releaseConnection()
                       throws java.sql.SQLException
Does nothing at all, we rely on the connection handling of the application server

Throws:
java.sql.SQLException

releaseConnection

public void releaseConnection(java.sql.Connection con)
                       throws java.sql.SQLException
Calls the connection's close function which is supposed to cause a fast logical releasement.

Throws:
java.sql.SQLException