1

I am trying to connect to database using DB2JDBC Type 2 driver. Below is my java code

try
{
    
    String urlPrefix = "jdbc:db2:";
     String url = urlPrefix + paramString1;
       String user = paramString2;
        String password = paramString3;
        
  log.debug(context, 1010, "Connecting to : " + paramString1);
  
  Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
  localConnection = DriverManager.getConnection(url, user, password);
  localConnection.setAutoCommit(false);
  

I have added db2java.zip to my calss path and db2jdbc.dll is available in C:\Program Files (x86)\IBM\SQLLIB\BIN(Prior to this error I faced db2jdbc.dll not found error)

enter image description here

When I run my code am getting java.sql.SQLException: No suitable driver exception. What am I missing. Should I check the versions of the driver I have downloaded.

0

2 Answers 2

2

DB2 JDBC Type 2 Driver is discontinued since Db2 10.1.

Resolution

Use the IBM Data Server Driver for JDBC and SQLJ instead of the DB2 JDBC Type 2 Driver. Refer to the task Upgrading database applications and subtask Upgrading Java applications that use DB2 JDBC Type 2 driver.

If you use the DB2 JDBC Type 2 Driver to compile your Java applications or routines, you will receive an error as the driver cannot be found.

Sign up to request clarification or add additional context in comments.

Comments

0

Java package names are class sensitive. The "COM" needs to be in lowercase:

Class.forName("com.ibm.db2.jdbc.app.DB2Driver").newInstance();
// Here--------^

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.