Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 02-05-2004, 06:18 AM   #1 (permalink)
 
Newb Techie

Join Date: Jan 2004

Posts: 6

9727604

Cool DataSource Problem

Hi all,
I am trying to access my database using a DataSource but I am encountering a problem and have tried in vain to find a solution(code snipet and stacktrace given below). I am using websphere application server and the database is Oracle 9i. I the server running. Any help would be greatly appreciated.

Thanks

String dsName1 = "jdbc/UpaidPool"; // JNDI name
DataSource ds1 = null;
Connection conn = null;

/**
* Construct an access object.
*/
public access ()
{
try
{
Context ctx = new InitialContext();
ds1 = (DataSource)ctx.lookup(dsName1); // Problem here

} catch (Exception e) {
e.printStackTrace();
}
}
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(N amingManager.java:647)
at javax.naming.InitialContext.getDefaultInitCtx(Init ialContext.java:247)
at javax.naming.InitialContext.getURLOrDefaultInitCtx (InitialContext.java:284)
at javax.naming.InitialContext.lookup(InitialContext. java:351)
at access.<init>(access.java:19)
at access.main(access.java:58)
java.lang.NullPointerException
at access.performread(access.java:34)
at access.main(access.java:59)
Exception in thread "main" Process terminated with exit code 1
9727604 is offline  
Old 02-05-2004, 11:57 AM   #2 (permalink)
 
Newb Techie

Join Date: Jan 2004

Posts: 6

9727604

Default

I have added the appropriate jar files to my classpath and tnow the error seems to have migrated to the DataSource as opposed to the Initial Context. I now get a different error (Stack trace below). Any Ideas?

com.ibm.websphere.naming.CannotInstantiateObjectEx ception: Exception occurred wh
ile the JNDI NamingManager was processing a javax.naming.Reference object. Root
exception is javax.naming.NamingException: ClassNotFoundException: oracle.jdbc.
pool.OracleConnectionPoolDataSource
at com.ibm.websphere.advanced.cm.factory.DataSourceFa ctory$ResourceRefer
enceObjectFactory.getObjectInstance(DataSourceFact ory.java:705)
at javax.naming.spi.NamingManager.getObjectInstance(N amingManager.java:3
08)
at com.ibm.ws.naming.util.Helpers.processSerializedOb jectForLookup(Helpe
rs.java:737)
at com.ibm.ejs.ns.jndi.CNContextImpl.processResolveRe sults(CNContextImpl
.java:1594)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNConte xtImpl.java:1470)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContext Impl.java:1120)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCt x.java:128)
at javax.naming.InitialContext.lookup(InitialContext. java:351)
at access.<init>(access.java:25)
at access.main(access.java:64)
Exception in thread "P=343:O=0:CT" java.lang.NullPointerException
at access.performread(access.java:40)
at access.main(access.java:65)
9727604 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On