• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassNotFoundException: AS400JDBCDriver

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am connecting to Db2 on AS400 and i get the following error. I really appreciate some helping me on this.
java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver
at java.net.URLClassLoader.findClass(URLClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:514)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:441)
at java.lang.ClassLoader.loadClass(ClassLoader.java:446)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:142)
at com.howost.databasewrapper.databaseconnection.DatabaseConnection.getDB2Connection(DatabaseConnection.java:92)
at com.howost.databasewrapper.databaseconnection.DatabaseAbstract.setDB2SQL(DatabaseAbstract.java:78)
at TestDataConnect.DatabaseTestMain.main(DatabaseTestMain.java:36)
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:563)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at com.howost.databasewrapper.databaseconnection.DatabaseConnection.getDB2Connection(DatabaseConnection.java:102)
at com.howost.databasewrapper.databaseconnection.DatabaseAbstract.setDB2SQL(DatabaseAbstract.java:78)
at TestDataConnect.DatabaseTestMain.main(DatabaseTestMain.java:36)

____________________________________________________________________________
The code is as follows
___________________________________________________________________________
public class DatabaseConnection extends DatabaseAbstract
implements DatabaseConnectionInterface{


private String uri;
private String userName;
private String password;
private String server;
private String databaseName;
protected Connection conn = null;

/**
*
* Constructor to be used for connecting to Oracle or Microsoft SQL
*
*/
public DatabaseConnection(String uri, String userName, String pass)
throws SQLException{



this.uri = uri;
this.userName = userName;
this.password = pass;



}
/**
*
* Constructor to be used for connecting to AS400
*
*/
public DatabaseConnection(String server, String userName, String pass, String databaseName)
throws SQLException{
System.out.println("Database Connection !!!");

this.server = server;

this.userName = userName;
this.password = pass;
this.databaseName = databaseName;


}

/**
*
* Returns a URI String for AS400 Connection
*
*/

public String getDbUrl(){
return "jdbc:as400://" + server + "/" + databaseName + ";prompt=false";
}


/**
* Provides implementation to get the
* connection to Db2 on AS400
*
*/
public Connection getDB2Connection(){
System.out.println("Getting Coonection /n");
System.out.println("URL is !!!" + getDbUrl());

try{
System.out.println("DRIVER is !!!" + DB2_DRIVER);
Class.forName(DB2_DRIVER);


}

catch (ClassNotFoundException cnfe){
System.out.println("Error Loading DB2 Driver..../n");
cnfe.printStackTrace();
}

try {
conn = DriverManager.getConnection(getDbUrl(), userName, password);
}catch(SQLException sqle){
sqle.printStackTrace();
System.out.println("Please check the Driver information provided");
}

return conn;

}

}
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The exception, "java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver", indicates that the JAR file containing your DB2 drivers isn't in your classpath. When you do a "Class.forName(...)" the classloader tries to find the specified class, but in your case it can't find the class.
I don't know how you are invoking your class, whether it's a client app or web application. Just make sure that your database driver class is in your classpath.
 
vikram nalagampalli
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply wayne, I am wondering, if you can also tell me how i can set path for the DB2 drivers within WSAD 5.0.
I am trying to execute through normal client app (i.e from with the main())

Originally posted by Wayne L Johnson:
The exception, "java.lang.ClassNotFoundException: com.ibm.as400.access.AS400JDBCDriver", indicates that the JAR file containing your DB2 drivers isn't in your classpath. When you do a "Class.forName(...)" the classloader tries to find the specified class, but in your case it can't find the class.
I don't know how you are invoking your class, whether it's a client app or web application. Just make sure that your database driver class is in your classpath.


[ September 30, 2003: Message edited by: vikram nalagampalli ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic