Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » JDBC Connection for Java ( IBM Data Studio )(Java codes for JDBC)
JDBC Connection for Java ( IBM Data Studio ) [message #957149] Thu, 25 October 2012 02:59 Go to next message
Bert Hernandez is currently offline Bert HernandezFriend
Messages: 4
Registered: October 2012
Junior Member
package SMART;

import java.sql.*;
public class HelloWorld {
public static void main(String[] args) {
try
{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Connection con = DriverManager.getConnection("jdbc:db2:/localhost:50000/CSP");
Statement statement = con.createStatement();
String createProductTable="CREATE TABLE PRODUCT"+
"(NAME VARCHAR(64)," +
"ID VARCHAR(32) NOT NULL," +
"PRICE FLOAT," +
"DESC VARCHAR(256)," +
"PRIMARY KEY(ID))";
statement.executeUpdate(createProductTable);
}
catch(Exception e){ e.printStackTrace();
}
}

}

- Everytime I run this . This error always pop out
" java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver
at java.lang.Class.forName(Class.java:139)
at SMART.HelloWorld.main(HelloWorld.java:8) "

They have said that my Class.forName has no source. Also if I needed to attach a source? what is it and where will I find it?

Best Regards,
G.L Hernandez
Re: JDBC Connection for Java ( IBM Data Studio ) [message #957827 is a reply to message #957149] Thu, 25 October 2012 14:24 Go to previous messageGo to next message
Eclipse UserFriend
> - Everytime I run this . This error always pop out
> " java.lang.ClassNotFoundException: COM.ibm.db2.jdbc.app.DB2Driver
> at java.lang.Class.forName(Class.java:139)
> at SMART.HelloWorld.main(HelloWorld.java:8) "
>
> They have said that my Class.forName has no source. Also if I needed to
> attach a source? what is it and where will I find it?
>
> Best Regards,
> G.L Hernandez


It basically says it can't find that class (i.e. ClassNotFoundException
means it can't find that class). That is the old obsolete type 2 DB2
driver. You should be using the now standard com.ibm.db2.jcc.DB2Driver
which is in the db2jcc.jar from DB2.

Rich
Re: JDBC Connection for Java ( IBM Data Studio ) [message #957873 is a reply to message #957827] Thu, 25 October 2012 15:08 Go to previous messageGo to next message
Bert Hernandez is currently offline Bert HernandezFriend
Messages: 4
Registered: October 2012
Junior Member
Okay sir. Thank you very much for the answer. I will try this ASAP
Re: JDBC Connection for Java ( IBM Data Studio ) [message #957908 is a reply to message #957827] Thu, 25 October 2012 15:41 Go to previous messageGo to next message
Bert Hernandez is currently offline Bert HernandezFriend
Messages: 4
Registered: October 2012
Junior Member
Still same error sir Rich . What should I do?
Re: JDBC Connection for Java ( IBM Data Studio ) [message #958006 is a reply to message #957908] Thu, 25 October 2012 17:16 Go to previous message
Eclipse UserFriend
It means it is not in your classpath. Make sure that the db2jcc.jar is
in your classpath for your launch configuration. (Using the com. not
COM. class name in Class.forName("...")

On 10/25/2012 11:41 AM, Bert Hernandez wrote:
> Still same error sir Rich . What should I do?
Previous Topic:ECJ usage in eclipse plugin
Next Topic:[SOLVED] generated equals missing not null check
Goto Forum:
  


Current Time: Tue Apr 23 08:55:56 GMT 2024

Powered by FUDForum. Page generated in 0.03861 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top