DataSource Problem

Status
Not open for further replies.

9727604

Solid State Member
Messages
6
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(NamingManager.java:647)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.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
 
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.CannotInstantiateObjectException: 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.DataSourceFactory$ResourceRefer
enceObjectFactory.getObjectInstance(DataSourceFactory.java:705)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:3
08)
at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookup(Helpe
rs.java:737)
at com.ibm.ejs.ns.jndi.CNContextImpl.processResolveResults(CNContextImpl
.java:1594)
at com.ibm.ejs.ns.jndi.CNContextImpl.doLookup(CNContextImpl.java:1470)
at com.ibm.ejs.ns.jndi.CNContextImpl.lookup(CNContextImpl.java:1120)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.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)
 
Status
Not open for further replies.
Back
Top Bottom