• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error when getting a connection from DB2 DB

 
Sriram Anbarasu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am getting the following error when I try to get the connection from a Db2 DB. I am running the program from WSAD 5.1.2 IDE. All the class path and the required JAR files are properly set in my IDE.

Error:
java.lang.NoClassDefFoundError: java/lang/CharSequence
at com.ibm.db2.jcc.c.p.<init>(p.java:52)
at com.ibm.db2.jcc.b.b.<init>(b.java:256)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:163)
at java.sql.DriverManager.getConnection(DriverManager.java:543)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at org.javacamp.factory.TestConnection.getDirectConnection(TestConnection.java:108)
at org.javacamp.factory.TestConnection.main(TestConnection.java:118)
Exception in thread "main"

Program:
public static Connection getDirectConnection()
throws Exception {
Connection connection = null;
try {
// load the DB2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
connection = DriverManager.getConnection("jdbc:db2://10.239.24.178:50000/CDWSOFF","userName","password");
} catch (Exception ex) {

}
return connection;
}
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CharSequence is an interface in java.lang which we hardly ever use, but String implements it. It is possible that something has gone wrong with your basic Java installation.

Remember the String class is one of the first ever loaded; it is called for the parameters for the main method, so the JVM will look for CharSequence when it loads String.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sriram,
Interface "CharSequence" was introduced with java 1.4, according to its javadoc.
According to the stack trace you posted, it appears that the JDBC driver you are using does not recognize it.
Logical inference is perhaps your JDBC driver is not compatible with java 1.4, or higher?

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic