We are trying to connect and read information from DB2 tables running on Mainframe RACF.
Although IBM DB2 connector document states supported platforms as Linux, Unix and Windows, I am wondering if we can use JDBC connector to connect with DB2 running on Mainframe Z/OS and wanted to check if db2jcc.jar driver can be used. Happy to know if there are any other possible integration approaches here.
yes, it is possible to connect to DB2 on Mainframe with the JDBC Connector. Copy db2jcc.jar file to WEB-INF/lib and use com.ibm.db2.jcc.DB2Driver as JDBC Driver.
Copy db2jcc.jar file to WEB-INF/lib and use com.ibm.db2.jcc.DB2Driver as JDBC Driver.
It is best to put JDBC driver into Tomcat’s lib directory instead, if there is a chance you will have another web application running in the same Tomcat server.
The StackOverflow answer stated memory-leak as a reason. There is actually another reason to not put JDBC drivers inside any web application.
In my previous job, a vendor made the same mistake of putting JDBC driver in IdentityIQ’s WEB-INF/lib folder. The database was MS SQL, and integrated authentication was used. MS SQL implements integrated authentication via a native library, invoked from MS SQL JDBC driver via JNI.
Which means, when loading the MS SQL JDBC driver, it will load a native library in turn.
Later, when another database-using web application was introduced, this new application would startup faster than IdentityIQ. The JDBC driver got loaded into the VM (under this web application’s classloader), and the MS SQL native library as well (under the JVM).
Then when it is IdentityIQ’s turn, it tries to load the JDBC driver again. The Java part loaded successfully (under IdentityIQ’s classloader), but the native library won’t, because JVM only allows a single instance of a native library, regardless of which classloader you are using. And so IdentityIQ fail to create any JDBC connection.
Putting the MS SQL JDBC driver into Tomcat\lib will load the JDBC driver exactly once (under Tomcat’s classloader). Then both web applications can use it.
So in short, put JDBC drivers in Tomcat\lib, not inside any web applications. It will probably save you from future headaches.