• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Getting InitialContext to access datasource

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm having trouble accessing a datasource from WSAD 5.0 in a stand-alone program. Please note that its a stand-alone program.
The code I use is as follows -
Hashtable Parms = new Hashtable();
Parms.put(Context.INITIAL_CONTEXT_FACTORY, AnalysisConstants.INITIAL_CONTEXT_FACTORY);
Parms.put(Context.PROVIDER_URL, "iiop://remotehost:2809");
InitialContext DBContext = new InitialContext(Parms);
DBSource = (DataSource) DBContext.lookup(strJNDIName);
....
But this is giving the following exception when I run it!
java.lang.IncompatibleClassChangeError: com.ibm.CORBA.iiop.ORB method createObjectURL(Ljava/lang/String Lcom/ibm/CORBA/iiop/ObjectURL;
at com.ibm.ws.naming.util.WsnInitCtxFactory.parseIiopUrl(WsnInitCtxFactory.java:1668)
at com.ibm.ws.naming.util.WsnInitCtxFactory.parseBootstrapURL(WsnInitCtxFactory.java:1427)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:368)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:102)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:408)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:131)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
Please help.
Thnx,
Sam
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, there are several problems here. First of all, you can't access InitialContexts or other things in a Standalone program and hope to make sense out of any of it -- it has to be a J2EE client program to make that work reasonably. Thus, your best solution is to create a J2EE client JAR file associated with an EAR project and do things that way.
However, the bigger problem you're going to run into is that even J2EE client programs don't have a well-defined way of accessing DataSources. This isn't going to work with WAS 5 datasources in any case. There is a way of doing this with WAS 4 datasources (see the infocenter) but it's not something you want to try to do.
Instead, STRONGLY consider doing the database update in an EJB and calling the EJB from your client program.
Kyle
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic