0

I am using the following code (provided on the official page of IBM, [here][1]) to create a connection to IBM DB2:

import jaydebeapi, sys

#Enter the values for you database connection
dsn_database = "testdb"# e.g. "BLUDB" Name of the database
dsn_hostname = "localhost"# e.g.: "bluemix05.bluforcloud.com"
dsn_port = "50000"# e.g. "50000" Database port number
dsn_uid = "DB2INST1"# e.g. "dash104434" User id
dsn_pwd = "123456789"# e.g. "7dBZ3jWt9xN6$o0JiX!m" User password for the database

connection_string='jdbc:db2://'+dsn_hostname+':'+dsn_port+'/'+dsn_database
if (sys.version_info >= (3,0)):
    conn = jaydebeapi.connect("com.ibm.db2.jcc.DB2Driver", connection_string, [dsn_uid, dsn_pwd])
else:
    conn = jaydebeapi.connect("com.ibm.db2.jcc.DB2Driver", [connection_string, dsn_uid, dsn_pwd])


  [1]: https://www.ibm.com/support/knowledgecenter/en/SSGNPV_1.1.3/dsx/createconnectionsdirect.html

And I am getting the following error:

AttributeError: '_jpype.PyJPField' object has no attribute 'getStaticAttribute'

What can I do to succeed?

1 Answers1

0

Seems like you have a version incompatibility. Your jaydebeapi version is calling for a private method in the jpype internal code which means that your jaydebeapi is out of date. I believe either backing off to jpype v 0.6.3 or updating to the latest jaydebeapi will correct your issue.

Karl Nelson
  • 336
  • 2
  • 3