• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Converting servlet to a WebSphere JDBC datasource

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}
}
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic