Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nullpointer exception while trying to connect

 
siva krishnan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Friends,

I am getting a strange problem.
I am trying to connect to a local Access DB through sun.jdbc.odbc.JdbcOdbcDriver.

The program works fine when I run it as a standalone program.
But the same piece of code gives a

java.lang.NullPointerException
at sun.jdbc.odbc.JdbcOdbcDriver.initialize(JdbcOdbcDriver.java:435)

when I run in the Websphere environment.

Are there any particular JARs that I need to replace in WSAD which might fix the problem. I did try replacing the rt.jar file in a couple of places in WSAD but I am still getting the nullpointer exception.

code snippet :

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc dbc:testDB","test", "test");
<<Exception is thrown at the above statement>>

Any suggestions ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default JVM for Websphere is provided by IBM, not Sun, and I'm not sure if it includes Suns's extra classes. This may be the problem you're running into.

Try installing the Sun JVM and configuring WAS to use this instead.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva,
IBM doesn't support WSAD or WebSphere App Server if you change the JVM. I strongly discourage you from doing that or trying to replace the rt.jar files. It may create other problems down the road. Instead add the Sun classes to your classpath.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A better solution of course would be to stop stop using Access and the JDBC-ODBC bridge. If you don't have DB2 there are a number of free databases which provide Type 2, 3 and 4 drivers.

(Now that I think back, we changed the JVM running applications inside WSAD and not the JVM for WSAD itself. This was caused by an incompatibility between the IBM and SUN RMI implementations - the two can't talk to each other )
 
siva krishnan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Now that I think back, we changed the JVM running applications inside WSAD and not the JVM for WSAD itself. )


Could you please elaborate on this ?
How do we change the JVM running applications inside WSAD ?

Due to limitations, we have to use the Access DB for this application.

Thank you for your advice.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34422
347
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva,
When you run an application (with a main method) in WSAD, it picks the JVM based on the one you specified in the project properties. Each project can use a different JVM and none of them have to be the same as the one WSAD itself is running under. (WSAD/Eclipse is java based and therefore needs a JVM.)

If you are running a server app (web project, ejb project), the situation is more complex. To the best of my knowledge, you can't switch that JVM as WSAD is tied to the server.
 
siva krishnan
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne....I will try the approach you suggest.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic