Reputation: 31
I need to connect to a DB2 database server using jdbc
from Eclipse. Even 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.
Upvotes: 2
Views: 19206
Reputation: 1217
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
Upvotes: 0
Reputation: 308998
Upvotes: 1