org.jaffa.persistence.engines.jdbcengine.datasource
Class JndiDataSourceConnectionFactory

java.lang.Object
  extended byorg.jaffa.persistence.engines.jdbcengine.datasource.JndiDataSourceConnectionFactory
All Implemented Interfaces:
IConnectionFactory

public class JndiDataSourceConnectionFactory
extends Object
implements IConnectionFactory

This is a JNDI specific implementation of IConnectionFactory. It assumes that the Jdbc Engine is being executed in the same VM in which a DataSource has already been defined. It will use JNDI to get a handle on the DataSource resource and a Connection from that DataSource.

Author:
GautamJ

Constructor Summary
JndiDataSourceConnectionFactory()
           
 
Method Summary
 Connection createConnection()
          Creates a connection using the DataSource obtained via JNDI.
 void freeConnection(Connection connection)
          Returns the connection back to the pool.
 String getJndiDataSourceName()
          Getter for property jndiDataSourceName.
 Long getMaxWait()
          Getter for property maxWait.
 void setJndiDataSourceName(String jndiDataSourceName)
          Setter for property jndiDataSourceName.
 void setMaxWait(Long maxWait)
          Setter for property maxWait.
 boolean usePreparedStatementCaching()
          Returns a true if the Prepared (and Call) Statements are to be cached for a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiDataSourceConnectionFactory

public JndiDataSourceConnectionFactory()
Method Detail

getJndiDataSourceName

public String getJndiDataSourceName()
Getter for property jndiDataSourceName.

Returns:
Value of property jndiDataSourceName.

setJndiDataSourceName

public void setJndiDataSourceName(String jndiDataSourceName)
Setter for property jndiDataSourceName.

Parameters:
jndiDataSourceName - New value of property jndiDataSourceName.

getMaxWait

public Long getMaxWait()
Getter for property maxWait.

Returns:
Value of property maxWait.

setMaxWait

public void setMaxWait(Long maxWait)
Setter for property maxWait.

Parameters:
maxWait - New value of property maxWait.

createConnection

public Connection createConnection()
                            throws SQLException,
                                   IOException
Creates a connection using the DataSource obtained via JNDI.

Specified by:
createConnection in interface IConnectionFactory
Returns:
a Connection
Throws:
SQLException - if any SQL error occurs
IOException - if any IO error occurs

freeConnection

public void freeConnection(Connection connection)
                    throws SQLException,
                           IOException
Returns the connection back to the pool.

Specified by:
freeConnection in interface IConnectionFactory
Parameters:
connection - The connection to return back to the pool.
Throws:
SQLException - if any SQL error occurs
IOException - if any IO error occurs

usePreparedStatementCaching

public boolean usePreparedStatementCaching()
Returns a true if the Prepared (and Call) Statements are to be cached for a connection. This will return a false. The JNDI DataSource is expected to specify a pool for the PreparedStatements.

Specified by:
usePreparedStatementCaching in interface IConnectionFactory
Returns:
a true if the Prepared (and Call) Statements are to be cached for a connection.


Copyright © 2002-2004 JAFFA Project.