net.sourceforge.pbeans.data
Class GenericDataSource

java.lang.Object
  extended by net.sourceforge.pbeans.data.GenericDataSource
All Implemented Interfaces:
javax.sql.DataSource

public class GenericDataSource
extends java.lang.Object
implements javax.sql.DataSource

An implementation of DataSource that can be used with any JDBC driver. The caller is required to set properties driverClassName and url.


Constructor Summary
GenericDataSource()
           
GenericDataSource(java.lang.String driverClassName, java.lang.String url)
           
 
Method Summary
 java.sql.Connection getConnection()
           
protected  java.sql.Connection getConnection(java.util.Properties properties)
           
 java.sql.Connection getConnection(java.lang.String username, java.lang.String password)
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 void setDriverClassName(java.lang.String dcn)
          Sets mandatory property driverClassName, the name of the JDBC Driver class (e.g.
 void setLoginTimeout(int seconds)
           
 void setLogWriter(java.io.PrintWriter out)
           
 void setProperties(java.util.Properties properties)
          Sets properties passed to Driver.connect method.
 void setUrl(java.lang.String url)
          Sets mandatory property url, the JDBC connection URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericDataSource

public GenericDataSource()

GenericDataSource

public GenericDataSource(java.lang.String driverClassName,
                         java.lang.String url)
                  throws java.lang.IllegalAccessException
Throws:
java.lang.IllegalAccessException
Method Detail

setDriverClassName

public void setDriverClassName(java.lang.String dcn)
Sets mandatory property driverClassName, the name of the JDBC Driver class (e.g.


setUrl

public void setUrl(java.lang.String url)
Sets mandatory property url, the JDBC connection URL.


setProperties

public void setProperties(java.util.Properties properties)
Sets properties passed to Driver.connect method. Properties typically needed are user and password, if they are not passed as part of the URL.


getConnection

protected java.sql.Connection getConnection(java.util.Properties properties)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String username,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getLoginTimeout

public int getLoginTimeout()
Specified by:
getLoginTimeout in interface javax.sql.DataSource

getLogWriter

public java.io.PrintWriter getLogWriter()
Specified by:
getLogWriter in interface javax.sql.DataSource

setLoginTimeout

public void setLoginTimeout(int seconds)
Specified by:
setLoginTimeout in interface javax.sql.DataSource

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
Specified by:
setLogWriter in interface javax.sql.DataSource