org.pojava.persistence.jndi
Class DriverManagerDataSource

java.lang.Object
  extended by org.pojava.persistence.jndi.DriverManagerDataSource
All Implemented Interfaces:
DataSource

public class DriverManagerDataSource
extends Object
implements DataSource

DriverManagerDataSource provides a simple DataSource object useful for unit testing.

Author:
John Pile

Constructor Summary
DriverManagerDataSource(String url, String user, String password)
          Create a DataSource that uses the DriverManager to provide the connection.
 
Method Summary
 Connection getConnection()
          Retrieve a new connection from the DriverManager
 Connection getConnection(String userName, String password)
          Retrieve a new connection for a specific userName and password.
 int getLoginTimeout()
          Return the loginTimeout value that really isn't used.
 PrintWriter getLogWriter()
          Return the logWriter that is initially set to DriverManager's logWriter.
 boolean isWrapperFor(Class<?> type)
          Unsupported.
 void setLoginTimeout(int time)
          Set the loginTimeout value that really isn't used.
 void setLogWriter(PrintWriter logWriter)
          Set your own custom logWriter.
<T> T
unwrap(Class<T> c)
          Compulsory unwrap method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DriverManagerDataSource

public DriverManagerDataSource(String url,
                               String user,
                               String password)
Create a DataSource that uses the DriverManager to provide the connection.

Parameters:
url -
user -
password -
Method Detail

getConnection

public Connection getConnection()
                         throws SQLException
Retrieve a new connection from the DriverManager

Specified by:
getConnection in interface DataSource
Throws:
SQLException

getConnection

public Connection getConnection(String userName,
                                String password)
                         throws SQLException
Retrieve a new connection for a specific userName and password.

Specified by:
getConnection in interface DataSource
Throws:
SQLException

getLoginTimeout

public int getLoginTimeout()
Return the loginTimeout value that really isn't used.

Specified by:
getLoginTimeout in interface DataSource

unwrap

public <T> T unwrap(Class<T> c)
Compulsory unwrap method. Unsupported.


setLoginTimeout

public void setLoginTimeout(int time)
Set the loginTimeout value that really isn't used.

Specified by:
setLoginTimeout in interface DataSource

getLogWriter

public PrintWriter getLogWriter()
Return the logWriter that is initially set to DriverManager's logWriter.

Specified by:
getLogWriter in interface DataSource

setLogWriter

public void setLogWriter(PrintWriter logWriter)
Set your own custom logWriter.

Specified by:
setLogWriter in interface DataSource

isWrapperFor

public boolean isWrapperFor(Class<?> type)
Unsupported.



Copyright © 2011. All Rights Reserved.