connect DB2 with Java

后端 未结 9 1652
梦谈多话
梦谈多话 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:40

    Well, you first need to have the DB2 Driver in your classpath; namely the db2jcc4.jar file. A syntax mistake that I noticed is:-

    You have the line as follows

    conn = DriverManager.getConnection("jdbc:db2:sabarish","db2admin","Murugasaranam"); _______________________________________^^^_________________________________

    You should add two forward slash characters(/) after db2: and before sabarish like this

    conn = DriverManager.getConnection("jdbc:db2://sabarish","db2admin","Murugasaranam")

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

    Driver name is depends on the driver we are using.
    Use COM.ibm.db2.jdbc.app.DB2Drive when db2java.zip is in your path.
    Use com.ibm.db2.jcc.DB2Driver when db2jcc.jar & db2jcc_license_cu.jar are in your classpath.

    Also follow the below tutorial
    Razorsql Help
    IBM JDBC help

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

    These two drivers are loaded from different JARs. The latter is loaded from jt400.

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

    for db2 old 8.x version you need to add this driver com.ibm.db2.jcc.DB2Driver

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

    Neither of the examples above worked for me, but this did:

    Class.forName("com.ibm.as400.access.AS400JDBCDriver");
    
    0 讨论(0)
  • 2021-02-02 16:49

    You need to correct the package name.

    Class.forName("com.ibm.db2.jdbc.app.DB2Driver");
    

    To add .jar in your project => Project + Properties + Java Build Path + Select "Libraries" tab + Add External Jars...

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