Cannot get ibm_db working on Linux

338 views
Skip to first unread message

David Palmer

unread,
Jul 2, 2018, 7:52:00 AM7/2/18
to ibm_db
Hello,

I'm trying (and failing) to get idb_db working correctly on Linux in my workplace.  I think this might be related to licensing.  I can get it working fine in Windows, where I have IBM DB2 client software installed, but not in Linux, where I do not - I have just installed the idb_db module using pip.  I've been advised by our DB2 DBAs that we have DB2 Connect Unlimited installed on our mainframe.

Windows

C:\Users\me>python
Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>> conn = ibm_db.connect("DATABASE=XXXX;HOSTNAME=XXXX;PORT=50000;PROTOCOL=TCPIP;UID=XXXX;PWD=XXXX;","","")
>>> sql = "SELECT STRINGID, SUBSTR(STRING,1,60) AS STRING FROM SYSIBM.SYSXMLSTRINGS ORDER BY STRINGID FETCH FIRST 3 ROWS ONLY"
>>> stmt = ibm_db.exec_immediate(conn, sql)
>>>

Linux

me@my_host: python
Python 2.7.14 (default, Oct 12 2017, 15:50:02) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ibm_db
>>> conn = ibm_db.connect("DATABASE=XXXX;HOSTNAME=XXXX;PORT=50000;PROTOCOL=TCPIP;UID=XXXX;PWD=XXXX;","","")
>>> sql = "SELECT STRINGID, SUBSTR(STRING,1,60) AS STRING FROM SYSIBM.SYSXMLSTRINGS ORDER BY STRINGID FETCH FIRST 3 ROWS ONLY"
>>> stmt = ibm_db.exec_immediate(conn, sql)
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
Exception: [IBM][CLI Driver] SQL30081N  A communication error has been detected. Communication protocol being used: "TCP/IP".  Communication API being used: "SOCKETS".  Location where the error was detected: "180.33.59.107".  Communication function detecting the error: "recv".  Protocol specific error code(s): "*", "*", "0".  SQLSTATE=08001 SQLCODE=-30081
>>>


Any suggestions please?

Saba Kauser

unread,
Jul 2, 2018, 7:59:29 AM7/2/18
to ibm_db

Looks like your server goes down while executing the statement. can you check if server is up all the time?
If you are connecting to z/OS, you need to have license from both windows and linux clients. ibm_db would install the client automatically and you would see clidirver under egg folder on your linux ibm_db install.

you can browse for sql30081 error in IBM Db2 infocenter if that can help you.

David Palmer

unread,
Jul 2, 2018, 11:04:53 AM7/2/18
to ibm_db
Thanks.  I'm sure the server doesn't go down.  I can see clidriver folders in both Windows and Linux so I think it is installed on both.  How would I be able to confirm if we have license for both Windows and Linux for z/OS?

Saba Kauser

unread,
Jul 2, 2018, 11:10:17 AM7/2/18
to ibm_db
hmm. that's very simple. had you not have valid license, your connection would not go through in first place. You would see SQL8001N error that says "An attempt to connect to the database failed due to a product license problem."
If you have client side license, it can be seen under clidriver/license folder. If you are using db2 connect unlimited edition for system z, it would have been activated at server by running db2connectactivate utility from client. This utility would install license SP @server that would be invoked while connecting to database to validate the license.
The problem you are facing is not due to license.

David Palmer

unread,
Jul 8, 2018, 11:12:03 PM7/8/18
to ibm_db
Thanks for the response.

I haven't run db2connectactivate utility from client, just installed the ibm_db module using pip.  If pip install doesn't do that, can you advise how I would do this from client?

I'm still confused why the same script works fine on Windows, but fails on Linux.  Our DBAs have suggested a trace, but because I don't have any client software installed, just ibm_db module, I don't think I can do this.  Can you suggest anything that would help with diagnosing the problem?  I looked at the error mesages relating to Protocol specific error code(s): "*", "*", "0". and it seemed to relate to a communication issue.

Thanks

Saba Kauser

unread,
Jul 8, 2018, 11:30:11 PM7/8/18
to ibm_db
Hello David,
As I understand, you have a Db2 database residing on windows. You can connect to it from windows where you have local client, but can't connect it from remote client on Linux.
The error 30081 implies your database server is not setup correctly for incoming connections to it.

Can you do the following at your windows machine:
1. db2 update dbm cfg using svcename 50000 (you can as well pass the svcename from services file, e.g db2c_DB2)
other technote that might help you is:

2. db2set DB2COMM=TCPIP
3. Check if your c:\Windows\system32\drivers\etc\services has entry for your port. My instance is DB2 and entry looks like this :
db2c_DB2        50000/tcp
If it does not exist for you, add one.
4. db2 terminate
5. db2stop
6. db2start

Go back to your remote client and check the connection again.

HTH.
Reply all
Reply to author
Forward
0 new messages