org.cid.distribution.plugins.db
Class ConnectionComponent

java.lang.Object
  extended by org.cid.distribution.base.DistributionComponentBase
      extended by org.cid.distribution.plugins.db.ConnectionComponent
All Implemented Interfaces:
DistributionContextAware, DistributionComponent, ConnectionProvider

public class ConnectionComponent
extends DistributionComponentBase
implements ConnectionProvider

The ConnectionComponent holds a connection to a database manager. This is used by other plugins in the db package to work with relational databases.

The ConnectionComponent uses the JDBC API to access different database manager systems. To access each particular database system, JDBC uses a library called JDBC driver. Distribution does not include JDBC drivers in the package so you will have to get them yourself.

To install the JDBC driver just drop it in distribution the lib, or alternatively place it in any directory in your Java classpath directory.

Each JDBC driver uses a different syntax to define a database connection. Check your JDBC driver docs to know how to express your database connection URL.

Example configuration:

 
   com.mysql.jdbc.Driver
   jdbc:mysql://host:3306/database?autoReconnect=true
   username
   password
  
 ]]>
 

This element stablishes a single connection to a data source. The connection cannot be reused. If you need more than one connection, duplicate the component ore use a ConnectionPoolComponent.

Version:
$Revision:111 $

Constructor Summary
ConnectionComponent()
          Class constructor.
 
Method Summary
static void addRules(org.apache.commons.digester.Digester d, java.lang.String patternPrefix)
          Configures additional rules for the commons-digester library.
 void destroy()
          When destroyed, this component logs information about the process.
 java.sql.Connection getConnection()
          Returns the database connection.
 java.lang.String getDriverClass()
           
 java.lang.String getPassword()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 void init()
          Initializes the ConnectionComponent.
 void setDriverClass(java.lang.String driverClass)
           
 void setPassword(java.lang.String password)
           
 void setUrl(java.lang.String url)
           
 void setUsername(java.lang.String username)
           
 
Methods inherited from class org.cid.distribution.base.DistributionComponentBase
getId, setDistributionContext, setId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionComponent

public ConnectionComponent()
Class constructor.

Method Detail

addRules

public static void addRules(org.apache.commons.digester.Digester d,
                            java.lang.String patternPrefix)
Configures additional rules for the commons-digester library.


init

public void init()
          throws DistributionProcessingException,
                 DistributionConfigurationException
Initializes the ConnectionComponent.

Specified by:
init in interface DistributionComponent
Overrides:
init in class DistributionComponentBase
Throws:
DistributionProcessingException
DistributionConfigurationException
See Also:
DistributionComponentBase.init()

destroy

public void destroy()
             throws DistributionProcessingException,
                    DistributionConfigurationException
When destroyed, this component logs information about the process.

Specified by:
destroy in interface DistributionComponent
Overrides:
destroy in class DistributionComponentBase
Throws:
DistributionProcessingException
DistributionConfigurationException

getConnection

public java.sql.Connection getConnection()
                                  throws DistributionProcessingException
Returns the database connection.

Specified by:
getConnection in interface ConnectionProvider
Returns:
Throws:
DistributionProcessingException

getDriverClass

public java.lang.String getDriverClass()
Returns:
Returns the driverClass.

setDriverClass

public void setDriverClass(java.lang.String driverClass)
Parameters:
driverClass - The driverClass to set.

getPassword

public java.lang.String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - The password to set.

getUrl

public java.lang.String getUrl()
Returns:
Returns the url.

setUrl

public void setUrl(java.lang.String url)
Parameters:
url - The url to set.

getUsername

public java.lang.String getUsername()
Returns:
Returns the username.

setUsername

public void setUsername(java.lang.String username)
Parameters:
username - The username to set.


Copyright © 2006 null. All Rights Reserved.