Java Reference
In-Depth Information
L ISTING 7.6
Continued
// Check our initial values
if ( driver == null ) {
throw new Exception(“No Driver Name Specified!”);
}
if ( url == null ) {
throw new Exception(“No URL Specified!”);
7
}
if ( size < 1 ) {
throw new Exception(“Pool size is less than 1!”);
}
// Create the Connections
try {
// Load the Driver class file
Class.forName(driver);
// Create Connections based on the size member
for ( int x = 0; x < size; x++ ) {
System.err.println(“Opening JDBC Connection “ + x);
Connection con = createConnection();
if ( con != null ) {
// Create a PooledConnection to encapsulate the
// real JDBC Connection
PooledConnection pcon = new PooledConnection(con);
// Add the Connection to the pool
addConnection(pcon);
}
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
catch (ClassNotFoundException cnfe) {
 
Search WWH ::




Custom Search