org.jboss.minerva.factories
Class JDBCConnectionFactory

java.lang.Object
  |
  +--org.jboss.minerva.pools.PoolObjectFactory
        |
        +--org.jboss.minerva.factories.JDBCConnectionFactory

public class JDBCConnectionFactory
extends PoolObjectFactory

Object factory that creates java.sql.Connections. This is meant for use outside a J2EE/JTA environment - servlets alone, client/server, etc. If you're interested in creating transactional-aware connections, see XAConnectionFactory, which complies with the JDBC 2.0 standard extension.

Version:
$Revision: 1.5 $
Author:
Aaron Mulder (ammulder@alumni.princeton.edu)
See Also:
XAConnectionFactory

Constructor Summary
JDBCConnectionFactory()
          Creates a new factory.
 
Method Summary
 java.lang.Object createObject()
          Creates a new JDBC Connection.
 void deleteObject(java.lang.Object pooledObject)
          Closes a connection.
 java.util.Properties getConnectProperties()
          Gets the JDBC Properties used to create new connections.
 java.lang.String getConnectURL()
          Gets the JDBC URL used to create new connections.
 java.lang.String getPassword()
          Gets the JDBC password used to create new connections.
 java.lang.String getUser()
          Gets the JDBC user name used to create new connections.
 void poolClosing(ObjectPool pool)
          Cleans up.
 void poolStarted(ObjectPool pool, java.io.PrintWriter log)
          Validates that connection properties were set (at least a URL).
 java.lang.Object prepareObject(java.lang.Object pooledObject)
          Wraps the connection with a ConnectionInPool.
 java.lang.Object returnObject(java.lang.Object clientObject)
          Closes all outstanding work for the connection, rolls it back, and returns the underlying connection to the pool.
 void setConnectProperties(java.util.Properties props)
          Sets the JDBC Propeties used to create new connections.
 void setConnectURL(java.lang.String url)
          Sets the JDBC URL used to create new connections.
 void setPassword(java.lang.String password)
          Sets the JDBC password used to create new connections.
 void setUser(java.lang.String userName)
          Sets the JDBC user name used to create new connections.
 java.lang.Object translateObject(java.lang.Object clientObject)
          Returns the original connection from a ConnectionInPool.
 
Methods inherited from class org.jboss.minerva.pools.PoolObjectFactory
isUniqueRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCConnectionFactory

public JDBCConnectionFactory()
Creates a new factory. You must configure it with JDBC properties before you can use it.
Method Detail

setConnectURL

public void setConnectURL(java.lang.String url)
Sets the JDBC URL used to create new connections.

getConnectURL

public java.lang.String getConnectURL()
Gets the JDBC URL used to create new connections.

setConnectProperties

public void setConnectProperties(java.util.Properties props)
Sets the JDBC Propeties used to create new connections. This is optional, and will only be used if present.

getConnectProperties

public java.util.Properties getConnectProperties()
Gets the JDBC Properties used to create new connections.

setUser

public void setUser(java.lang.String userName)
Sets the JDBC user name used to create new connections. This is optional, and will only be used if present.

getUser

public java.lang.String getUser()
Gets the JDBC user name used to create new connections.

setPassword

public void setPassword(java.lang.String password)
Sets the JDBC password used to create new connections. This is optional, and will only be used if present.

getPassword

public java.lang.String getPassword()
Gets the JDBC password used to create new connections.

poolStarted

public void poolStarted(ObjectPool pool,
                        java.io.PrintWriter log)
Validates that connection properties were set (at least a URL).
Overrides:
poolStarted in class PoolObjectFactory
Following copied from class: org.jboss.minerva.pools.PoolObjectFactory
Parameters:
pool - The pool that is starting. You may decide to allow multiple pools you use your factory, or to restrict it to a one-to-one relationship.
log - A writer you can use to log messages. Use this in preference to System.xxx.println.
Throws:
java.lang.IllegalArgumentException - Occurs when the pool is null.

poolClosing

public void poolClosing(ObjectPool pool)
Cleans up.
Overrides:
poolClosing in class PoolObjectFactory
Following copied from class: org.jboss.minerva.pools.PoolObjectFactory
Parameters:
pool - The pool that is closing. You may decide to allow multiple pools you use your factory, or to restrict it to a one-to-one relationship.
Throws:
java.lang.IllegalArgumentException - Occurs when the pool is null.

createObject

public java.lang.Object createObject()
Creates a new JDBC Connection.
Overrides:
createObject in class PoolObjectFactory
Following copied from class: org.jboss.minerva.pools.PoolObjectFactory
See Also:
PoolObjectFactory.prepareObject(java.lang.Object)

prepareObject

public java.lang.Object prepareObject(java.lang.Object pooledObject)
Wraps the connection with a ConnectionInPool.
Overrides:
prepareObject in class PoolObjectFactory
See Also:
ConnectionInPool

translateObject

public java.lang.Object translateObject(java.lang.Object clientObject)
Returns the original connection from a ConnectionInPool.
Overrides:
translateObject in class PoolObjectFactory
See Also:
ConnectionInPool

returnObject

public java.lang.Object returnObject(java.lang.Object clientObject)
Closes all outstanding work for the connection, rolls it back, and returns the underlying connection to the pool.
Overrides:
returnObject in class PoolObjectFactory
Following copied from class: org.jboss.minerva.pools.PoolObjectFactory
Parameters:
clientObject - The client object, as returned by prepareObject
Returns:
The pooled object, as originally returned by createObject, ready to be put back in the pool and reused.

deleteObject

public void deleteObject(java.lang.Object pooledObject)
Closes a connection.
Overrides:
deleteObject in class PoolObjectFactory


Copyright © 2000 The jBoss Organization. All Rights Reserved.