File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Error when getting a connection from DB2 DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error when getting a connection from DB2 DB" Watch "Error when getting a connection from DB2 DB" New topic
Author

Error when getting a connection from DB2 DB

Sriram Anbarasu
Greenhorn

Joined: Dec 09, 2005
Posts: 4
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;
}


Regards,<br />Sriram.A
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
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

Joined: Oct 11, 2000
Posts: 1135

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error when getting a connection from DB2 DB