Why is the DB2 Type 4 JDBC driver looking for the db2jcct2 native library?

I thought the Type 4 JDBC driver is pure Java and does not require the use of native libraries.

When I put db2jcc4.jar in the WEB-INF / lib directory of my Tomcat application, packaged as a .war file, when I try to use the application, the following message appears: Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError

The corresponding application code is as follows, and an exception is thrown due to the last line in the list:

  import com.ibm.db2.jcc.DB2SimpleDataSource; // ... DB2SimpleDataSource main_db2_data_source = new DB2SimpleDataSource(); main_db2_data_source.setUser(main_database_user); main_db2_data_source.setPassword(main_database_password); main_db2_data_source.setServerName(main_database_host); try { Integer main_database_port_integer = Integer.parseInt(main_database_port); main_db2_data_source.setPortNumber(main_database_port_integer); } catch (NumberFormatException exception) { throw new WebException("..."); } Connection main_connection = null; try { main_connection = main_db2_data_source.getConnection(); 
+4
source share
4 answers

I suspect the problem is that you did not tell him to use a type 4 driver - I think the same jar file contains drivers of types 4 and 2.

Try:

 main_db2_data_source.setDriverType(4); 
+15
source

The db2 driver needs another bank, which includes a license.

This license controls the type of connection. If you intend to use "db2 connect" to connect to the mainframe as an i-series, you must use the appropriate license. If you intend to connect to Linux UNIX or a Windows server, the license is included when you receive a " " Data Server Client for JDBC "

+2
source

Also try the following:

 Goto Configure Build Path --> Libraries --> JRE System Libraries --> Native Library Location : Set this to %DB2HOME%/BIN (which is where db2jcct2.dll is saved) 
+1
source

I recently ran into this problem when I connected to DB2 from a Glassfish server. To do this, I followed these steps and resolved this issue. Please check it below.

step1) I checked the details of DB2 in the Domain.xml file. I only saw the username, pwd, databaseName, server_name, port number, but I do not see DriverType. Tool Driver Type 2 or 4.

2) to add the type of driver that I registered in the Glassfish server admin console

Resources -> JDBC -> Connection Pool -> our pool - add an additional property

I added here since drivertype is 4.

Therefore, my problem is resolved.

Thank you, Ramaya Pillala.

0
source

Source: https://habr.com/ru/post/1383858/


All Articles