开发者

DB2 Connection Issue using JDBC from eclipse

I need to connect to a DB2 database server using jdbc from Eclipse. Ev开发者_如何学编程en though I have already installed the required jar file, I am getting the following error:

Error occurred java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
Error occurred java.sql.SQLException: No suitable driver found for jdbc:db2://db2server

What do I do?

Thanks.


  1. Make sure the JAR containing com.ibm.db2.jcc.DB2Driver is in your CLASSPATH.
  2. If it is, check the URL syntax. That error usually means that the driver class was loaded, but the URL was incorrect. Here are the docs to show you what the correct syntax is.
  3. If both of those look right, make sure that the server name is visible from your machine. Ping that machine name; find out that you have it in your hosts table.


I had similar issue.

Well I tried to download IBM Driver and the Downloaded folder also contains db2jcc.jar and db2jcc4.jar put both these jars in WEB-INF/lib folder all do add them in classpath (Build path options). also your code must look something like this,

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

        //context
        //DataSource datasource = null;
    //  datasource = (DataSource)initCtx.lookup("jdbc:sqlserver://AZNICSQL02;DatabaseName=CIO;schemaName=dbo");


        //Connect to Data source
        dbconnection = DriverManager.getConnection("jdbc:db2://192.168.4.58:50001/", "", "");
        dbstatement = (Statement) dbconnection.createStatement();`

Try exploring in DataSource Explorer plugin in eclipse

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜