raccoon.core.jdbc
Class ConnectionDriver

java.lang.Object
  extended by raccoon.core.types.AbsComponent
      extended by raccoon.core.types.AbsLoadable
          extended by raccoon.core.types.AbsConfigurableLoadable
              extended by raccoon.core.jdbc.ConnectionDriver
All Implemented Interfaces:
java.sql.Driver, IBaseComponent, IConfigurable, ILoadable, ILogable, IConnectionDriver

public class ConnectionDriver
extends AbsConfigurableLoadable
implements IConnectionDriver

A simple JDBC Driver to provide pooling capabilities to Raccoon in a none container context.

Since:
Raccoon v0.9
Version:
0.9
Author:
Cedric ROUVRAIS

Field Summary
 
Fields inherited from class raccoon.core.types.AbsConfigurableLoadable
mConfigurableManager
 
Fields inherited from class raccoon.core.types.AbsLoadable
mIsLoaded
 
Fields inherited from class raccoon.core.types.AbsComponent
mIsInError
 
Fields inherited from interface raccoon.api.utils.IConnectionDriver
PTY_CONNECTION_DRIVER, PTY_CONNECTION_URL, PTY_DATABASE_DRIVER, PTY_USER_NAME, PTY_USER_PWD, URL_PREFIX
 
Constructor Summary
ConnectionDriver()
           
ConnectionDriver(java.lang.String pDriver, java.lang.String pUrl, java.lang.String pUser, java.lang.String pPassword)
           
 
Method Summary
 boolean acceptsURL(java.lang.String url)
          Retrieves whether the driver thinks that it can open a connection to the given URL.
 void configureParameters()
          Configures the various parameters for this component.
 java.sql.Connection connect(java.lang.String pUrl, java.util.Properties pInfo)
          Attempts to make a database connection to the given URL.
 java.lang.String getConnectionUrl()
          The URL connnection string to the database.
 java.lang.String getDatabaseDriver()
          The name of the database driver.
 int getMajorVersion()
          Retrieves the driver's major version number.
 int getMinorVersion()
          Gets the driver's minor version number.
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)
          Gets information about the possible properties for this driver.
 java.lang.String getUrl()
          The database URL to use to retrieve a connection from this pool.
 java.lang.String getUserName()
          The name of the user for database connection.
 java.lang.String getUserPwd()
          The password associated to the provided user.
 boolean jdbcCompliant()
          Reports whether this driver is a genuine JDBC CompliantTM driver.
 void load()
          Loads or initializes the component.
 void setConnectionUrl(java.lang.String pConnectionUrl)
          Defines the URL connection to the database.
 void setDatabaseDriver(java.lang.String pDatabaseDriver)
          Defines the database driver to use.
 void setUserName(java.lang.String pUserName)
          Defines the user name to use for the connection.
 void setUserPwd(java.lang.String pUserPwd)
          Defines the password of the provided user.
 
Methods inherited from class raccoon.core.types.AbsConfigurableLoadable
isStable, setConfigurableManager, setLogger
 
Methods inherited from class raccoon.core.types.AbsLoadable
getLog, isInError, isInitialised, isRunning, unload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionDriver

public ConnectionDriver()

ConnectionDriver

public ConnectionDriver(java.lang.String pDriver,
                        java.lang.String pUrl,
                        java.lang.String pUser,
                        java.lang.String pPassword)
                 throws java.sql.SQLException,
                        java.lang.ClassNotFoundException
Throws:
java.sql.SQLException
java.lang.ClassNotFoundException
Method Detail

getUrl

public java.lang.String getUrl()
The database URL to use to retrieve a connection from this pool.

Specified by:
getUrl in interface IConnectionDriver
Returns:
the URL to use.

configureParameters

public void configureParameters()
Configures the various parameters for this component. This method should configure the instance of IConfigurableManager provided during the invocation of AbsConfigurableLoadable.setConfigurableManager(raccoon.api.types.IConfigurableManager).

Specified by:
configureParameters in interface IConfigurable
Overrides:
configureParameters in class AbsConfigurableLoadable

getDatabaseDriver

public java.lang.String getDatabaseDriver()
The name of the database driver.

Returns:
the class name of the JDBC driver.

setDatabaseDriver

public void setDatabaseDriver(java.lang.String pDatabaseDriver)
                       throws ResourceNotFoundException
Defines the database driver to use.

Parameters:
pDatabaseDriver - the name of the database driver.
Throws:
ResourceNotFoundException - in case of an internal error.

getConnectionUrl

public java.lang.String getConnectionUrl()
The URL connnection string to the database.

Returns:
the url

setConnectionUrl

public void setConnectionUrl(java.lang.String pConnectionUrl)
                      throws ResourceNotFoundException
Defines the URL connection to the database.

Parameters:
pConnectionUrl - the url connection string.
Throws:
ResourceNotFoundException

getUserName

public java.lang.String getUserName()
The name of the user for database connection.

Returns:
the user name.

setUserName

public void setUserName(java.lang.String pUserName)
                 throws ResourceNotFoundException
Defines the user name to use for the connection.

Parameters:
pUserName - the user name.
Throws:
ResourceNotFoundException

getUserPwd

public java.lang.String getUserPwd()
The password associated to the provided user.

Returns:
the password string.
See Also:
#getUserName()}

setUserPwd

public void setUserPwd(java.lang.String pUserPwd)
Defines the password of the provided user.

Parameters:
pUserPwd - the password of the user for the database.

load

public void load()
          throws java.lang.IllegalStateException,
                 LoadableException
Loads or initializes the component.

Specified by:
load in interface ILoadable
Overrides:
load in class AbsConfigurableLoadable
Throws:
LoadableException - if the component couldn't load itself.
java.lang.IllegalStateException - if the component isn't in a state to load itself. for example it is already loaded.

connect

public java.sql.Connection connect(java.lang.String pUrl,
                                   java.util.Properties pInfo)
                            throws java.sql.SQLException
Attempts to make a database connection to the given URL. The driver should return "null" if it realizes it is the wrong kind of driver to connect to the given URL. This will be common, as when the JDBC driver manager is asked to connect to a given URL it passes the URL to each loaded driver in turn.

The driver should throw an SQLException if it is the right driver to connect to the given URL but has trouble connecting to the database.

The java.util.Properties argument can be used to pass arbitrary string tag/value pairs as connection arguments. Normally at least "user" and "password" properties should be included in the Properties object.

Specified by:
connect in interface java.sql.Driver
Parameters:
pUrl - the URL of the database to which to connect
pInfo - a list of arbitrary string tag/value pairs as connection arguments. Normally at least a "user" and "password" property should be included.
Returns:
a Connection object that represents a connection to the URL
Throws:
java.sql.SQLException - if a database access error occurs

acceptsURL

public boolean acceptsURL(java.lang.String url)
                   throws java.sql.SQLException
Retrieves whether the driver thinks that it can open a connection to the given URL. Typically drivers will return true if they understand the subprotocol specified in the URL and false if they do not.

Specified by:
acceptsURL in interface java.sql.Driver
Parameters:
url - the URL of the database
Returns:
true if this driver understands the given URL; false otherwise
Throws:
java.sql.SQLException - if a database access error occurs

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                     java.util.Properties info)
                                              throws java.sql.SQLException
Gets information about the possible properties for this driver.

The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties it should prompt a human for in order to get enough information to connect to a database. Note that depending on the values the human has supplied so far, additional values may become necessary, so it may be necessary to iterate though several calls to the getPropertyInfo method.

Specified by:
getPropertyInfo in interface java.sql.Driver
Parameters:
url - the URL of the database to which to connect
info - a proposed list of tag/value pairs that will be sent on connect open
Returns:
an array of DriverPropertyInfo objects describing possible properties. This array may be an empty array if no properties are required.
Throws:
java.sql.SQLException - if a database access error occurs

getMajorVersion

public int getMajorVersion()
Retrieves the driver's major version number. Initially this should be 1.

Specified by:
getMajorVersion in interface java.sql.Driver
Returns:
this driver's major version number

getMinorVersion

public int getMinorVersion()
Gets the driver's minor version number. Initially this should be 0.

Specified by:
getMinorVersion in interface java.sql.Driver
Returns:
this driver's minor version number

jdbcCompliant

public boolean jdbcCompliant()
Reports whether this driver is a genuine JDBC CompliantTM driver. A driver may only report true here if it passes the JDBC compliance tests; otherwise it is required to return false.

JDBC compliance requires full support for the JDBC API and full support for SQL 92 Entry Level. It is expected that JDBC compliant drivers will be available for all the major commercial databases.

This method is not intended to encourage the development of non-JDBC compliant drivers, but is a recognition of the fact that some vendors are interested in using the JDBC API and framework for lightweight databases that do not support full database functionality, or for special databases such as document information retrieval where a SQL implementation may not be feasible.

Specified by:
jdbcCompliant in interface java.sql.Driver
Returns:
true if this driver is JDBC Compliant; false otherwise


Copyright null null. All Rights Reserved.