connect DB2 with Java

后端 未结 9 1637
梦谈多话
梦谈多话 2021-02-02 16:28

I need to connect DB2 with Java. Kindly help me to connect DB2 with java in ECLIPSE. It would be of great help if you could guide me step by s

相关标签:
9条回答
  • 2021-02-02 16:49

    Please do try using

    Class.forName("com.ibm.db2.jcc.DB2Driver");
    

    Hopefully this link might help you a bit more. PUBLIB

    Regards

    0 讨论(0)
  • 2021-02-02 16:51

    Think you need to put db2jcc.jar on your classpath.

    0 讨论(0)
  • 2021-02-02 16:51

    Your URL is a T2 connectivity url.( "jdbc:db2:sabarish") The driver class you are using is from the legacy db2 jdbc driver which is out of support but still available inside db2 server installation e.g (C:\Program Files\IBM\SQLLIB\java\db2java.zip) in eclipse , right click on the java project-> select Properties. In properties window go to Java build Path. select libraries tab. click Add External Jars button and add the db2java.zip from the above db2 installation location.

    Recommendation: If you want to stay with latest db2 server and drivers, download the driver jars from the IBM fix central. http://www-01.ibm.com/support/docview.wss?uid=swg21363866 You need to register for first time to create an IBM id. In the bundle you will find db2jcc.jar its based on JDBC3 specification. In the bundle you will find db2jcc4.jar its based on JDBC4 specification. Add any one of the jar file in your project as mentioned above. load the driver class as below. Class.forName("com.ibm.db2.jcc.DB2Driver"); This supports both T2 and T4 connectivity.

    0 讨论(0)
提交回复
热议问题