wood burning stoves 2.0*
The moose likes Websphere and the fly likes Converting servlet to a WebSphere JDBC datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Converting servlet to a WebSphere JDBC datasource" Watch "Converting servlet to a WebSphere JDBC datasource" New topic
Author

Converting servlet to a WebSphere JDBC datasource

Jim Sloey
Greenhorn

Joined: Nov 07, 2002
Posts: 3
I have WebSphere 4.0 running in a clustered HA environment with separate web (2 IHS), application (4 clones, 2 nodes) and database (2 each DB2 & Oracle) tiers. Failover works perfectly on all tiers transparent to the users.
I have a servlet installed that was developed using Tomcat and Eclipse. When Oracle fails-over, this servlet gets a stale db connection and can't recover.
I am probably the worst Java programmer in the world, but I've traced this back to the following code that needs to be converted to use the WebSphere JDBC datasource named s1. Any help in converting would be grtly appreciated.
Thanks... Jim
package com.xgs.data.connection;
import oracle.jdbc.pool.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import com.xgs.data.exception.*;
public class DBConnectionPool {
OracleConnectionCacheImpl myConnectionPool;
OracleConnectionPoolDataSource myDataSource;
protected static OracleConnectionCacheImpl myConnectionCache = null ;
protected static String dbURL ;
protected static String dbUserName ;
protected static String dbPassword ;
protected static int minLimit ;
protected static int maxLimit ;
public synchronized static OracleConnection getDataSource() throws SQLException {
if ( myConnectionCache == null ) {
OracleConnectionPoolDataSource myDataSource = new OracleConnectionPoolDataSource();
myDataSource.setURL( dbURL ) ;
myDataSource.setUser( dbUserName ) ;
myDataSource.setPassword( dbPassword ) ;
// Associate it with the Cache
myConnectionCache = new OracleConnectionCacheImpl ( myDataSource );
// Set the Max Limit
myConnectionCache.setMinLimit (minLimit) ;
myConnectionCache.setMaxLimit (maxLimit) ;
// Set the Scheme
myConnectionCache.setCacheScheme (OracleConnectionCacheImpl.DYNAMIC_SCHEME );
}
return (OracleConnection ) myConnectionCache.getConnection();
}
/**
* Returns the dbPassword.
* @return String
*/
public static String getDbPassword() {
return dbPassword;
}
/**
* Returns the dbURL.
* @return String
*/
public static String getDbURL() {
return dbURL;
}
/**
* Returns the dbUserName.
* @return String
*/
public static String getDbUserName() {
return dbUserName;
}
/**
* Sets the dbPassword.
* @param dbPassword The dbPassword to set
*/
public static void setDbPassword(String dbPassword) {
DBConnectionPool.dbPassword = dbPassword;
}
/**
* Sets the dbURL.
* @param dbURL The dbURL to set
*/
public static void setDbURL(String dbURL) {
DBConnectionPool.dbURL = dbURL;
}
/**
* Sets the dbUserName.
* @param dbUserName The dbUserName to set
*/
public static void setDbUserName(String dbUserName) {
DBConnectionPool.dbUserName = dbUserName;
}
/**
* Returns the maxLimit.
* @return int
*/
public static int getMaxLimit() {
return maxLimit;
}
/**
* Returns the minLimit.
* @return int
*/
public static int getMinLimit() {
return minLimit;
}
/**
* Sets the maxLimit.
* @param maxLimit The maxLimit to set
*/
public static void setMaxLimit(int maxLimit) {
DBConnectionPool.maxLimit = maxLimit;
}
/**
* Sets the minLimit.
* @param minLimit The minLimit to set
*/
public static void setMinLimit(int minLimit) {
DBConnectionPool.minLimit = minLimit;
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting servlet to a WebSphere JDBC datasource
 
Similar Threads
oracle statement caching in connection pool
JDBC Connection
Connecting to Oracle from Java
Oracle Drivers
Null Pointer Exception running RMI Client