Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2006

    Unanswered: Cannot instanciate

    Hi all,

    I would like to connect remotely to the DB2 in linux machine using the JNDI lookup.

    In websphere development 5.1, this portion of code is working in 5.1 env :

    Context MyCtx = null;
    DataSource MyDS = null;
    Hashtable parms = new Hashtable();
    Connection conn = null;

    " tory ");

    MyCtx = new InitialContext(parms);
    MyDS = (DataSource) MyCtx.lookup("jdbc/Employee");
    conn = MyDS.getConnection();


    But after i recompile in websphere rational 6.0 in windows XP env, the code is not working anymore. It said :

    => Cannot instanciate .

    I have imported the db2jcc.jar, db2jcc_license_cu.jar, can anyone giv me some clue what is happening? Thanks alot.

  2. #2
    Join Date
    Apr 2003
    This is how to do it using SJSAS, I'm confident it will work with any server by supplying the correct URI and port numbers (and of course including the correct jars in your classpath):

    1. Add three Java archives (JARs) to your class path in the lib directory of Application Server's root installation directory: j2ee.jar, appserv-rt.jar, and appserv-admin.jar.
    2. Set the values for the Java virtual machine startup options, as follows:

    jvmarg value = "-Dorg.omg.CORBA.ORBInitialHost=${ORBhost}"
    jvmarg value = "-Dorg.omg.CORBA.ORBInitialPort=${ORBport}"

    where ORBhost is Application Server's host name and ORBport is the ORB port number, whose default is 3700 for the default instance. You can obtain that information from the domain.xml file on the remote system. For details on that file, see Chapter 1 in Sun Java System Application Server Enterprise Edition 8.1 Administration Reference.
    Here is an example of the compilation command line (all on one line):
    java -classpath.;c:\Sun\AppServer.ib\j2ee.jar;c:\Sun\App Server.ib\appservrt.jar;c:\Sun\AppServer.ib\appser v-admin.jar-Dorg.omg.CORBA.ORBInitialHost=localhost-Dorg.omg.CORBA.ORBInitialPort=3700 MEJBStandaloneClient ejb/mgmt/MEJB
    This looks up EJB resources, but JDBC resources should be no different.

    I've seen a lot of people trying what you did (and tried it myself just on the off chance it might work and to see why it didn't).
    It's not only something that (generally) won't work (might work inside the container but don't count on it) but it's bad programming practice as it introduces a hard dependency on a specific appserver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts