| JDBC Connection for Java ( IBM Data Studio ) [message #957149] |
Wed, 24 October 2012 22:59  |
Bert Hernandez 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 10:24   |
|
> - 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 #958006 is a reply to message #957908] |
Thu, 25 October 2012 13:16  |
|
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?
|
|
|
Powered by
FUDForum. Page generated in 0.02037 seconds