o-tech
o-tech

Reputation: 21

ClassNotFoundException when using JDBC driver for DB2

I'm trying to connect to a DB2 database using JDBC. Therefore I downloaded the DB2 driver db2jcc.jar and added the path to the classpath while compiling and running my application (I'm not using an IDE). The following is the source of my Test-Application:

import java.sql.*;

public class TestApp {
    public static void main(String[] args){
        try {
            Class.forName("com.ibm.db2.jcc.DB2Driver");
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }
}

Does anybody know, where my problem is?

Upvotes: 0

Views: 2019

Answers (1)

Java Devil
Java Devil

Reputation: 10959

Try compiling:

'javac -cp ".;(path)/db2jcc.jar;(path)/db2jcc_license_cu.jar" TestApp.java' 

Then running

'java -cp ".;(path)/db2jcc.jar;(path)/db2jcc_license_cu.jar" TestApp' 

You only need quotes if spaces in the file/path names also.

Upvotes: 1

Related Questions