File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Error when getting a connection from DB2 DB" Watch "Error when getting a connection from DB2 DB" New topic

Error when getting a connection from DB2 DB

Sriram Anbarasu

Joined: Dec 09, 2005
Posts: 4

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.

java.lang.NoClassDefFoundError: java/lang/CharSequence
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at org.javacamp.factory.TestConnection.getDirectConnection(
at org.javacamp.factory.TestConnection.main(
Exception in thread "main"

public static Connection getDirectConnection()
throws Exception {
Connection connection = null;
try {
// load the DB2 Driver
connection = DriverManager.getConnection("jdbc:db2://","userName","password");
} catch (Exception ex) {

return connection;

Regards,<br />Sriram.A
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46337
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: 1141

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,
I agree. Here's the link:
subject: Error when getting a connection from DB2 DB
jQuery in Action, 3rd edition