Methods Summary |
---|
public java.lang.String | getDsn()The data source name of the data source this pool will use
to create its actual connections.
return dsn;
|
public java.io.PrintWriter | getLogWriter()
return logWriter;
|
public int | getLoginTimeout()
return loginTimeout;
|
public javax.sql.PooledConnection | getPooledConnection()Provides an application data source with a reference to
a pooled connection. The pooled connection represents
the physical connection to the database. Because this
library is an abstraction for the sake of statement pooling,
our physical connection is itself an abstraction. The job
of the physical connection is to provide the application
data source with a logical connection.
return getPooledConnection(null, null);
|
public javax.sql.PooledConnection | getPooledConnection(java.lang.String uid, java.lang.String pw)Provides an application data surce with a reference to a pooled
connection based on the specified authentication credentials.
if( loginTimeout > 0 ) {
ConnectionAttempt att = new ConnectionAttempt(dsn, uid, pw);
long start = System.currentTimeMillis();
long to = (long)(loginTimeout * 1000);
synchronized( att ) {
while( (System.currentTimeMillis() - start) < to ) {
try { att.wait(to); }
catch( InterruptedException e ) { }
if( att.connection != null ) {
return att.connection;
}
else if( att.exception != null ) {
throw att.exception;
}
else {
to = to - (System.currentTimeMillis() - start);
}
}
throw new SQLException("Connection timed out.");
}
}
else {
return new PhysicalConnection(dsn, uid, pw);
}
|
public void | setDsn(java.lang.String dsn)Sets the name of the data source to be used for generating connections.
this.dsn = dsn;
|
public void | setLogWriter(java.io.PrintWriter out)Assigns a print writer for logging.
logWriter = out;
|
public void | setLoginTimeout(int sec)Sets a new login timeout for this pool.
loginTimeout = sec;
|