FileDocCategorySizeDatePackage
DataSourceWrapper.javaAPI DocExample3735Tue Feb 28 11:34:06 GMT 2006com.ora.jsp.sql

DataSourceWrapper

public class DataSourceWrapper extends Object implements DataSource
This class is a wrapper implementing the JDBC 2.0 DataSource interface, used to make the ConnectionPool class look like a JDBC 2.0 DataSource.
author
Hans Bergsten, Gefion software
version
2.0

Fields Summary
private ConnectionPool
pool
private String
driverClassName
private String
url
private String
user
private String
password
private int
initialConnections
Constructors Summary
Methods Summary
private voidcreateConnectionPool()
Create a Connection pool based on the configuration properties.


        try {
            pool = new ConnectionPool(driverClassName, url, user,
                password, initialConnections);
        }
        catch (SQLException e) {
            throw e;
        }
        catch (Exception e) {
            SQLException sqle = 
                new SQLException("Error creating pool: " + 
                    e.getClass().getName() + " : " + e.getMessage());
            throw sqle;
        }
    
public java.sql.ConnectiongetConnection()
Gets a connection from the pool and returns it wrapped in a ConnectionWrapper.

        if (pool == null) {
            createConnectionPool();
        }
        return new ConnectionWrapper(pool.getConnection(), this);
    
public java.sql.ConnectiongetConnection(java.lang.String username, java.lang.String password)
Always throws an SQLException. Username and password are set with the setter methods and can not be changed.

        throw new SQLException("Not supported");
    
public java.io.PrintWritergetLogWriter()
Always throws an SQLException. Not supported.

        throw new SQLException("Not supported");
    
public intgetLoginTimeout()
Always throws an SQLException. Not supported.

        throw new SQLException("Not supported");
    
public voidreturnConnection(java.sql.Connection conn)
Returns a Connection to the pool. This method is called by the ConnectionWrapper's close() method.

        pool.returnConnection(conn);
    
public voidsetDriverClassName(java.lang.String driverClassName)
Sets the JDBC driver class name for the pool.

        this.driverClassName = driverClassName;
    
public voidsetInitialConnections(int initialConnections)
Sets the number of connections to create when the pool is created.

        this.initialConnections = initialConnections;
    
public synchronized voidsetLogWriter(java.io.PrintWriter out)
Always throws an SQLException. Not supported.

        throw new SQLException("Not supported");
    
public voidsetLoginTimeout(int seconds)
Always throws an SQLException. Not supported.

        throw new SQLException("Not supported");
    
public voidsetPassword(java.lang.String password)
Sets the user account password for the pool.

        this.password = password;
    
public voidsetUrl(java.lang.String url)
Sets the JDBC URL for the pool.

        this.url = url;
    
public voidsetUser(java.lang.String user)
Sets the user account for the pool.

        this.user = user;