com.xavax.xstore.util
Class DataSource

Object
  extended byDataSource
All Implemented Interfaces:
DataSource

public class DataSource
extends Object
implements DataSource

DataSource implements the javax.sql.DataSource interface using the driver manager.


Constructor Summary
DataSource(String name, String url, String username, String password, int poolSize)
          Construct a DataSource with the specified URL, username, and password.
 
Method Summary
 void close()
          Shut down the connection pool.
 Connection getConnection()
          Returns a connection to this data source.
 Connection getConnection(String username, String password)
          Returns a connection to this data source.
 int getLoginTimeout()
          Returns the login timeout.
 PrintWriter getLogWriter()
          Returns the log writer.
 void setLoginTimeout(int i)
          Set the login timeout.
 void setLogWriter(PrintWriter w)
          Set the log writer.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSource

public DataSource(String name,
                  String url,
                  String username,
                  String password,
                  int poolSize)
Construct a DataSource with the specified URL, username, and password.

Parameters:
url - the URL for connecting to the database using JDBC.
username - the username for authenticating a connection.
password - the password for authenticating a connection.
poolSize - the maximum number of connections in the pool.
Method Detail

getConnection

public Connection getConnection()
                                  throws SQLException
Returns a connection to this data source.

Specified by:
getConnection in interface DataSource
Returns:
a connection to this data source.
Throws:
SQLException - if the driver manager fails to open a connection.

getConnection

public Connection getConnection(String username,
                                String password)
                                  throws SQLException
Returns a connection to this data source.

Specified by:
getConnection in interface DataSource
Parameters:
username - the username (ignored).
password - the password (ignored).
Returns:
a connection to this data source.
Throws:
SQLException - if the driver manager fails to open a connection.

getLoginTimeout

public int getLoginTimeout()
Returns the login timeout.

Specified by:
getLoginTimeout in interface DataSource
Returns:
the login timeout.

getLogWriter

public PrintWriter getLogWriter()
Returns the log writer.

Specified by:
getLogWriter in interface DataSource
Returns:
the log writer.

setLoginTimeout

public void setLoginTimeout(int i)
Set the login timeout.

Specified by:
setLoginTimeout in interface DataSource
Parameters:
i - the new login timeout.

setLogWriter

public void setLogWriter(PrintWriter w)
Set the log writer.

Specified by:
setLogWriter in interface DataSource
Parameters:
w - the new log writer.

close

public void close()
Shut down the connection pool.