Reputation: 117
I try to connect from my Java-Application to an existing DB2 Database. My Code looks like a minimal version of the example shown at connect DB2 with Java.
public static void main(String[] argv) {
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
}
catch (ClassNotFoundException e) {
System.out.println("Please include Classpath Where your DB2 Driver is located");
e.printStackTrace();
return;
}
System.out.println("DB2 driver is loaded successfully");
}
When i run this the following error occurs:
java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
What are the requirements to connect to a DB2? I added db2jcc.jar and db2jcc_licence_cisuz.jar to the projects build-path and inside the db2jcc.jar exists an DB2Driver.class.
Do I have to configure sth. else?
Upvotes: 0
Views: 2255
Reputation: 117
As written in my comment above, I had to add the DB2-Dependency as described at http://www.mkyong.com/maven/how-to-include-library-manully-into-maven-local-repository/
This is because of my project-type: maven-based application. Just adding the jar-files to built-path was not enough. I had to add them to the repo and add it into my pom.xml.
Upvotes: 1