Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problem connecting to db2 through java in WDSC

Reply
Thread Tools

Problem connecting to db2 through java in WDSC

 
 
savita
Guest
Posts: n/a
 
      12-28-2006
Hello ,

I want to connect to IBM db2400 of AS400 through java in websphere.
The code I have written is follows


package com.jdbc;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Dbjdbc
{
public Dbjdbc()
{


}
public static void main(String args[])
{
try
{


Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch (ClassNotFoundException e)
{
System.err.println("Could not load DB2 driver \n");
System.err.println(e.getMessage());


}


try
{
//Connect to a database
Connection conn = DriverManager.getConnection
("jdbc:db2:192.168.0.10","SAVITA","SAVITA");


}
catch (SQLException e)
{
System.out.println("SQL Exception: ");
}
}



}


I am getting compile error as follows:-

---------------------------------------------------------------------------**---------------------------------------------------------



Could not load DB2 driver


com.ibm.db2.jcc.DB2Driver
SQL Exception:
---------------------------------------------------------------------------**----------------------------------------------------------



Does it mean I have to install the DB2 Universal JDBC Driver
com.ibm.db2.jcc.DB2Driver
If yes? Please let me know the step to be followed.How to do ?


Thanks
Regards
Savita

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-29-2006
savita wrote:
> I want to connect to IBM db2400 of AS400 through java in websphere.
> The code I have written is follows
>


> try
> {
>
>
> Class.forName("com.ibm.db2.jcc.DB2Driver");
> }
> catch (ClassNotFoundException e)
> {
> System.err.println("Could not load DB2 driver \n");
> System.err.println(e.getMessage());
>
>
> }
>
>
> try
> {
> //Connect to a database
> Connection conn = DriverManager.getConnection
> ("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
>
>
> }
> catch (SQLException e)
> {
> System.out.println("SQL Exception: ");
> }
> }
>
>
>
> }
>
>
> I am getting compile error as follows:-


No - you are getting a runtime error.

> Could not load DB2 driver
> com.ibm.db2.jcc.DB2Driver
> SQL Exception:


> Does it mean I have to install the DB2 Universal JDBC Driver
> com.ibm.db2.jcc.DB2Driver
> If yes? Please let me know the step to be followed.How to do ?


You need to put the jar file(s) with the DB2 JDBC driver in
your classpath.

db2jcc.jar and db2jcc_license_something.jar

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception thrown & Failure in loading T2 native library db2jcct2 while connecting to db2/400 through java savita Java 1 12-30-2006 03:37 PM
Connecting to db2/400 of AS400 through java throwing SQLException savita Java 4 12-30-2006 06:58 AM
DB2 under Windows XP - "Missing DB2 Libraries or headers" daf@jaade.com Ruby 0 04-26-2006 03:08 PM
Installing ruby-db2-0.4 for DB2 gives SQLConnect() errors. Dinesh Ruby 0 04-03-2006 04:20 AM
Hibernate 3.1 and db2 connecting using com.ibm.db2.jcc.DB2Driver crawstevenford@gmail.com Java 0 02-19-2006 08:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57