Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Problem connecting to db2 through java in WDSC

Thread view: 
savita - 28 Dec 2006 11:57 GMT
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
Arne Vajhøj - 29 Dec 2006 01:31 GMT
> I  want to connect to IBM db2400 of AS400 through java in websphere.
> The code I have written is follows

>                 try
>                 {
[quoted text clipped - 24 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.