Search code examples
javajdbcdb2xpageslotus-domino

Connect to a DB2 with JDBC from domino


I am trying to connect to a db2 database from my domino application without using the extension library.

I have created a managed bean that it only connects to the db2 and prints a message on the console.

I call the method of the managed bean from a button on an xpage.

The code in the bean is this:

Class.forName("com.ibm.db2.jcc.DB2Driver");
String url = "jdbc:db2://10.0.1.49:50000/AVIN";
String user = "db2admin";
String password = "ibmdb2";
con = DriverManager.getConnection(url, user, password);
System.out.println("Successful TEST JDBC Connection!!");

I have also configured my build path and added the db2jcc.jar library.

The problem is that i am getting

java.lang.ClassNotFoundException for com.ibm.db2.jcc.DB2Driver

Why is this happening?


Solution

  • Is the DB2 JDBC driver available to your application? I suspect not.

    You may need to package the driver in a plugin - within the NSF it will probably hit Java security issues and not work. More recent versions of the Extension Library (the Designer update site install) provide a menu option to Domino Designer to allow you to easily package up a JDBC driver as a plugin, which can then be deployed to your Update Site database.

    I strongly recommend using the Extension Library. It will provide robust connection pooling amongst other things. Without it, you may well hit problems already considered and resolved by the experience of the Extension Library developers. If you do hit problems, you may struggle to find anyone with the experience to help you.