• 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

Error when getting a connection from DB2 DB

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic