0
votes

I am developing for Websphere 8.5 (for z/OS), but i would like to use Liberty for local development on my Windows machine. I can't get the data source to work.

I created the following entry in the Server.xml to define the data source.

<library id="DB2JCC2Lib">
    <fileset dir="C:\Program Files\IBM\SQLLIB\java"/><!--includes="db2jcc.jar db2jcc_license_cu.jar db2jcc_license_cisuz.jar"-->
</library>

<dataSource id="xxdb" jndiName="jdbc/xxxx" type="javax.sql.ConnectionPoolDataSource">
    <jdbcDriver libraryRef="DB2JCC2Lib" id="db2-driver" javax.sql.ConnectionPoolDataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"/>

    <properties.db2.jcc driverType="2" databaseName="xxxx" portNumber="50000" user="xxxx" password="{aes}xxxx"/>
</dataSource>

When my application initializes i get the following error message:

[jcc][4038][12241][3.61.65] T2LUW exception: SQL30081N Kommunikationsfehler. Verwendetes Kommunikationsprotokoll: "TCP/IP". Verwendete Kommunikations-API: "SOCKETS". Position, an der der Fehler erkannt wurde: "127.0.0.1". Übertragungsfunktion, die den Fehler festgestellt hat: "connect". Protokollspezifische(r) Fehlercode(s): "10061", "", "". SQLSTATE=08001

I think this message comes from the db2 Driver, unfortunately i didn't find a way yet to change it to english; but i think it's understandable for english speakers.

I have an ODBC System datasource that connects to DB2 v10 maintenance level 015 for z/OS. My local DB2 Connect Installation is v9.7.300.3885.

In my regular Websphere my working datasource has driver type 2, database Name set to the odbc-name and port number 50000. Server name is not set (empty). Classpath and implementation class is the same that i provided in the server.xml

I have tried everything i could find, any ideas?

Note: I can't make changes on the db2 server and there is no issue connecting to the database with other tools and the regular WebSphere. Also the server name in the websphere configuration is empty, only database name is set. When i tried to set the servername in the server.xml to localhost or the db2 server i got the same result.

Any help is appreciated!

Edit: updated with correct Version Information

Edit 2: As long as it works i dont care what type (2 or 4) of the jdbc driver is used. I just want to point out again that type 2 is currently working on my machine. I tried it with type 4 and got the following message:

[jcc][t4][2043][11550][3.61.65] Exception java.net.ConnectException: Error opening socket to server xxx/xxx.30.3.34 on port 50,000 with message: Connection refused: connect. ERRORCODE=-4499, SQLSTATE=08001 DSRA0010E: SQL State = 08001, Error Code = -4,499

1
1. There's no "db2 v9.7 for z/OS" 2. You should not be using the type 2 driver. 3. The error message means that you are connecting to your local machine (127.0.0.1) instead of the actual database server, so your DSN definition is probably incorrect. - mustaccio
1 My mistake, i updated the post with the correct version 2 Like i said in my post, my reference installation uses type 2 and works fine. I just tried type 4 and get a similar error message 3 When i set serverName property to the db2server i get the same messsage but with the server ip instead of localhost. Like i said the DSN works fine, because i use it from my local Websphere application and from AQT (sql tool). The working configuration in Websphere has servername set to empty, thats why i ommitted it (i also read online that you shouldnt set it when using type 2 driver) - styx
The errors indicate that the DB2 instance is not running on your local machine on port 50000, or that the firewall prevents connections on that port. - mustaccio
The db2 instance is running on a remote z/OS machine. Locally i have an ODBC data source. My local websphere datasource uses a type 2 driver to connect to the remote z/OS db2 server (via a local ODBC datasource). There are no networking/firewall issues, the connection works fine on this machine (websphere datasource and SQL tool). In Liberty i get neither type 2 nor type 4 to work. - styx

1 Answers

1
votes

Sorry, previous post ate my xml. Trying again:

You will need a type 4 datasource to connect to a remote database server, i.e.,

<dataSource id="xxdb" jndiName="jdbc/xxxx" type="javax.sql.XADataSource">
<properties.db2.jcc driverType="4" serverName="the.db2.host.com" portNumber="50000" user="xxxx" password="xxxx" databaseName="LOC1" currentSQLID="SYSA"/>
<jdbcDriver libraryRef="DB2JCC2Lib">
</dataSource>

Type 2 is only for a local z/OS connection to a database resource. Your Windows, being remote from z/OS, requires you to use a type 4 connection. Type 4 requires both the serverName and portNumber to be specified. These are not applicable on a type 2 connection.