spring-bootjdbcdb2db2-luwjt400

spring-boot jdbc connection to db2 gets read timeouts


So I'm new to db2 and have to use it in a project soon, in order to prepare myself I used a db2express-c docker image.

From a soon to be co-worker I received the JT400 library to connect from my application to the docker container.

However I keep getting read timeouts when trying to connect to the db2 instance.
My jdbc-url looks like this jdbc:as400://127.0.0.1:50000;database name=TRFM;naming=system;thread used=false;errors=full;toolbox trace=all;trace=true;

After connecting to the db2 instance jdbc sends out some random bytes it seems, but it doesn't get a response back.
Below you'll find some extra information from the trace: Thread[restartedMain,5,main] Thu Aug 9 16:47:47:837 CEST 2018 Sending exchange random seeds request... Thread[restartedMain,5,main] Thu Aug 9 16:47:47:838 CEST 2018 Data stream sent (connID=337871951) ... 00 00 00 1C 01 00 E0 04 00 00 00 00 00 00 00 00 00 08 70 01 00 00 01 65 1F 28 6D 7D Thread[restartedMain,5,main] Thu Aug 9 16:47:47:838 CEST 2018 Receiving exchange random seeds reply... Thread[restartedMain,5,main] Thu Aug 9 16:48:07:842 CEST 2018 Establishing connection failed: java.net.SocketTimeoutException: Read timed out


Solution

  • You cannot use the JT400 library to talk to a Db2-for-Linux/Unix/Windows server. Instead, that driver is for communicating with Db2-for-i-Series.

    To work with Db2 for Linux/Unix/Windows, use one of the Db2 for LUW clients, available for download from http://www-01.ibm.com/support/docview.wss?uid=swg21363866 (IBM registration required).

    The Db2-express server in the docker container is Db2 for LUW. Remember that when you use Db2 for LUW, your URL must follow the pattern for Db2 for LUW as described in the Db2 for LUW Knowledge Centre.