toolbox.allegato
Class JDBCConfig

Package class diagram package JDBCConfig
java.lang.Object
  extended by toolbox.allegato.JDBCConfig

public class JDBCConfig
extends java.lang.Object

Encapsulates the configuration of a JDBC connection. The class provides access to all JDBC parameters specified in a XML element or set using the set methods.

The class also provides a method to establish the connection.


Constructor Summary
JDBCConfig()
          Default constructor
JDBCConfig(java.lang.String name, XMLProperties xmlProps)
          Initialises this config object with the given XML configuration
 
Method Summary
 java.sql.Connection createConnection()
          Creates a connection using the configuration properties of this configuration object and returns the connection.
 java.lang.String getConnectionString()
          Returns the connection string for this config object.
 java.lang.String getDriver()
          Returns the driver string for this config object.
 java.lang.String getPassword()
          Returns the password for this config object.
 java.lang.String getUserName()
          Returns the user name for this config object.
 void setConnectionString(java.lang.String connStr)
          Set the connection string for this config object.
 void setDriver(java.lang.String driver)
          Set the driver string for this config object.
 void setPassword(java.lang.String password)
          Set the password for this config object.
 void setUserName(java.lang.String userName)
          Set the user name for this config object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCConfig

public JDBCConfig()
Default constructor


JDBCConfig

public JDBCConfig(java.lang.String name,
                  XMLProperties xmlProps)
           throws ConfException
Initialises this config object with the given XML configuration

Parameters:
name - The name of the JDBC configuration
xmlProps - XML configuration properties containing a valid JDBCConfig element.
Throws:
ConfException - if this object cannot be initialised.
Method Detail

setDriver

public void setDriver(java.lang.String driver)
Set the driver string for this config object.

Parameters:
driver - Driver class name.

getDriver

public java.lang.String getDriver()
Returns the driver string for this config object.

Returns:
String containing the class name of the driver for this object.

setUserName

public void setUserName(java.lang.String userName)
Set the user name for this config object.

Parameters:
userName - User name used to establish database connection.

getUserName

public java.lang.String getUserName()
Returns the user name for this config object.

Returns:
String containing user name used by this object to establish a database connection.

setPassword

public void setPassword(java.lang.String password)
Set the password for this config object.

Parameters:
password - Password used by this object to establish a database connection.

getPassword

public java.lang.String getPassword()
Returns the password for this config object.

Returns:
String containing the password used by this object to establish database connection.

setConnectionString

public void setConnectionString(java.lang.String connStr)
Set the connection string for this config object.

Parameters:
connStr - Connection string used to establish a database connection. This is a driver specific string.

getConnectionString

public java.lang.String getConnectionString()
Returns the connection string for this config object.

Returns:
String containing the connection string used by this object to establish a database connection.

createConnection

public java.sql.Connection createConnection()
                                     throws java.sql.SQLException
Creates a connection using the configuration properties of this configuration object and returns the connection.

Returns:
Connection instance.
Throws:
java.sql.SQLException - if a database connection cannot be established.