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 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