org.objectweb.cjdbc.controller.connection
Class SimpleConnectionManager

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.connection.AbstractConnectionManager
      extended byorg.objectweb.cjdbc.controller.connection.SimpleConnectionManager
All Implemented Interfaces:
java.lang.Cloneable, XmlComponent

public class SimpleConnectionManager
extends AbstractConnectionManager

This connection manager creates a new Connection every time the getConnection()method is called.

Version:
1.0
Author:
Emmanuel Cecchet , Nicolas Modrzyk

Field Summary
private  int nbOfConnections
           
 
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
backendName, backendUrl, driverClassName, driverPath, initialized, logger, rLogin, rPassword
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
SimpleConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String login, java.lang.String password, java.lang.String driverPath, java.lang.String driverClassName)
          Creates a new SimpleConnectionManager instance.
 
Method Summary
private  void addConnection()
           
protected  java.lang.Object clone()
           
 void deleteConnection(java.sql.Connection c)
          Delete a connection that is no more valid.
 void finalizeConnections()
          Does nothing.
 java.sql.Connection getConnection()
          Gets a new connection from the underlying driver.
 int getCurrentNumberOfConnections()
          Get the current number of connections open for this connection manager.
 java.lang.String getXmlImpl()
          Gets xml formatted information on this connection manager
 void initializeConnections()
          Does nothing.
 void releaseConnection(java.sql.Connection connection)
          Closes the connection.
private  void removeConnection()
           
 
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager
copy, deleteConnection, finalize, getConnection, getConnectionFromDriver, getDriverClassName, getDriverPath, getLogin, getPassword, getVLogin, getXml, isInitialized, releaseConnection, retrieveConnection, setDriverClassName, setDriverPath, setLogin, setPassword, setVLogin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nbOfConnections

private int nbOfConnections
Constructor Detail

SimpleConnectionManager

public SimpleConnectionManager(java.lang.String backendUrl,
                               java.lang.String backendName,
                               java.lang.String login,
                               java.lang.String password,
                               java.lang.String driverPath,
                               java.lang.String driverClassName)
Creates a new SimpleConnectionManager instance.

Parameters:
backendUrl - URL of the DatabaseBackend owning this connection manager.
backendName - name of the DatabaseBackend owning this connection manager.
login - backend connection login to be used by this connection manager.
password - backend connection password to be used by this connection manager.
driverPath - path for driver
driverClassName - class name for driver
Method Detail

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Specified by:
clone in class AbstractConnectionManager
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

initializeConnections

public void initializeConnections()
                           throws java.sql.SQLException
Does nothing.

Specified by:
initializeConnections in class AbstractConnectionManager
Throws:
java.sql.SQLException - if an error occurs.
See Also:
AbstractConnectionManager.initializeConnections()

finalizeConnections

public void finalizeConnections()
                         throws java.sql.SQLException
Does nothing.

Specified by:
finalizeConnections in class AbstractConnectionManager
Throws:
java.sql.SQLException - if an error occurs.
See Also:
AbstractConnectionManager.finalizeConnections()

getConnection

public java.sql.Connection getConnection()
                                  throws UnreachableBackendException
Gets a new connection from the underlying driver.

Specified by:
getConnection in class AbstractConnectionManager
Returns:
a Connection or null if no connection is available or if the connection has not been initialized.
Throws:
UnreachableBackendException - if the backend must be disabled
See Also:
AbstractConnectionManager.getConnection()

releaseConnection

public void releaseConnection(java.sql.Connection connection)
Closes the connection.

Specified by:
releaseConnection in class AbstractConnectionManager
Parameters:
connection - the connection to release.
See Also:
AbstractConnectionManager.releaseConnection(Connection)

deleteConnection

public void deleteConnection(java.sql.Connection c)
Description copied from class: AbstractConnectionManager
Delete a connection that is no more valid.

Specified by:
deleteConnection in class AbstractConnectionManager
Parameters:
c - the connection to delete.
See Also:
AbstractConnectionManager.deleteConnection(Connection)

getCurrentNumberOfConnections

public int getCurrentNumberOfConnections()
Description copied from class: AbstractConnectionManager
Get the current number of connections open for this connection manager.

Specified by:
getCurrentNumberOfConnections in class AbstractConnectionManager
Returns:
the current number of open connections
See Also:
AbstractConnectionManager.getCurrentNumberOfConnections()

addConnection

private void addConnection()

removeConnection

private void removeConnection()

getXmlImpl

public java.lang.String getXmlImpl()
Description copied from class: AbstractConnectionManager
Gets xml formatted information on this connection manager

Specified by:
getXmlImpl in class AbstractConnectionManager
Returns:
xml formatted string that conforms to c-jdbc.dtd
See Also:
AbstractConnectionManager.getXmlImpl()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.