Vage Java 3.5 (Websphere Test Environment) Connection Pooling


EJB design: Vage Java 3.5 (Websphere Test Environment) Connection Pooling

  1. I am trying to use Connection Pool in servlets under WTE.
    I have defined appropriate Oracle DataSource (ORACLEDS) using WTE console features.

    When I tried to lookup Oracle DataSource and assign to DataSource object. I am getting Casting exception? Any suggestions? Below are the alternatives I have tried

    Alternative 1
      Context ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup("jdbc/ORACLEDS");

    Alternative 2
    Context ctx = new InitialContext();
    Object obj = ctx.lookup("jdbc/ORACLEDS");
    DataSource ds = (DataSource) PortableRemoteObject.narrow(obj,DataSource.class);
  2. Can you extract one more piece of information, ie: the actual type of the class you are getting back? Try saving it first as an Object and then call getClass().getName() to see what it is.