org.objectweb.easybeans.ds
Class DummyDataSource

java.lang.Object
  extended by org.objectweb.easybeans.ds.DummyDataSource
All Implemented Interfaces:
java.io.Serializable, javax.sql.DataSource

public class DummyDataSource
extends java.lang.Object
implements javax.sql.DataSource, java.io.Serializable

Defines a dummy datasource implementation based on HSQL in memory server.

Author:
florent
See Also:
Serialized Form

Field Summary
private static boolean bolLoadDriver
          Says if the driver must be load.
private  java.lang.String instanceName
          Name used for the instance name.
private static long serialVersionUID
          Id for serializable class.
 
Constructor Summary
DummyDataSource(java.lang.String name)
          Constructor.
Init the driver.
 
Method Summary
 java.sql.Connection getConnection()
          Attempts to establish a connection with the data source that this DataSource object represents.
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
          Attempts to establish a connection with the data source that this DataSource object represents.
 int getLoginTimeout()
          Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 java.io.PrintWriter getLogWriter()
          Retrieves the log writer for this DataSource object.
private  void loadDriver()
          Loads the JBDC driver if the driver is not loaded yet.
 void setLoginTimeout(int seconds)
          Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.
 void setLogWriter(java.io.PrintWriter out)
          Sets the log writer for this DataSource object to the given java.io.PrintWriter object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Id for serializable class.

See Also:
Constant Field Values

instanceName

private java.lang.String instanceName
Name used for the instance name.


bolLoadDriver

private static boolean bolLoadDriver
Says if the driver must be load.

Constructor Detail

DummyDataSource

public DummyDataSource(java.lang.String name)
Constructor.
Init the driver.

Parameters:
name - used for the instance name.
Method Detail

loadDriver

private void loadDriver()
Loads the JBDC driver if the driver is not loaded yet.


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException

Attempts to establish a connection with the data source that this DataSource object represents.

Specified by:
getConnection in interface javax.sql.DataSource
Returns:
a connection to the data source
Throws:
java.sql.SQLException - if a database access error occurs

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException

Attempts to establish a connection with the data source that this DataSource object represents.

Specified by:
getConnection in interface javax.sql.DataSource
Parameters:
username - the database user on whose behalf the connection is being made
password - the user's password
Returns:
a connection to the data source
Throws:
java.sql.SQLException - if a database access error occurs

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException

Retrieves the log writer for this DataSource object.

Specified by:
getLogWriter in interface javax.sql.DataSource
Returns:
the log writer for this data source or null if logging is disabled
Throws:
java.sql.SQLException - if a database access error occurs

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws java.sql.SQLException

Sets the log writer for this DataSource object to the given java.io.PrintWriter object.

Specified by:
setLogWriter in interface javax.sql.DataSource
Parameters:
out - the new log writer; to disable logging, set to null
Throws:
java.sql.SQLException - if a database access error occurs

setLoginTimeout

public void setLoginTimeout(int seconds)
                     throws java.sql.SQLException

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

Specified by:
setLoginTimeout in interface javax.sql.DataSource
Parameters:
seconds - the data source login time limit
Throws:
java.sql.SQLException - if a database access error occurs.

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.

Specified by:
getLoginTimeout in interface javax.sql.DataSource
Returns:
the data source login time limit
Throws:
java.sql.SQLException - if a database access error occurs.