Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class.forName return null

 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Class.forName("com.ibm.as400.access.AS400JDBCDriver") return with null.
Get this exception:
java.lang.ClassNotFoundException: sun.com.ibm.as400.access.AS400JDBCDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:325)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:257)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:134)
at dbaseMail.connect(dbaseMail.java:40)
at MailClientMass.DBConnect30(MailClientMass.java:204)
at MailClientMass.hentEmail(MailClientMass.java:163)
at MailClientMass.main(MailClientMass.java:247)
Anyone that can help me solve this problem?
 
Ken Robinson
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely the class you are attempting to load is not in your CLASSPATH.
 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is using websphere application developer. The Jar file that include the driver is in the classpath and also in the properties. The weird thing is that other classes in the same project find the driver. Other solutions?
 
Ken Robinson
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The fact that you are getting a ClassNotFound exception all but guarentees this is a Classpath problem.
Although you may be able to compile the code, the runtime envionment may be configured differently.
Is this a web app or standalone? The type of app and where you deploy/run has a big effect on what classes are available.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To see the classpath that your servlet is actually running under, use System.getProperty("java.class.path"). As Ken suggests, you may find your runtime configuration isn't what you think it is.
 
sdsharma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try importing the following:
import java.lang.Runtime;
import java.sql.*;
import oracle.jdbc.driver.*;
You may go two routes.
Route: 1 - You may put your Driver classes in your Oracle lib and set your classpath like this depending upon your Oracle environment.
D:\Oracle\Ora81\jdbc\lib\816classes12.zip;
Route: 2 - You may put your Driver classes in the lib folder of your App Server and set its classpath.
 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for the help. It was not in my classpath. This was easy to see when I used the code:
System.out.println(System.getProperty("java.class.path"));
Good tips!
thx all.
Age
 
Tracey Currier
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, this helped me, too.
Using 1.3.1 on IPlanet looking
for a jconnect driver (JDBC driver)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic