Logstash JDBC Input Plugin - DB2 - db2

I am trying to connect to DB2 database on Mainframe from my local machine. I am using JDBC input plugin. It seems the jdbc driver license file is not getting loaded. Can someone please tell me how can I load the db2jcc_license_cisuz-1.4.2.jar file.
I am using logstash version 6.2.2
I am able to connect to DB2 using the same license file from other Java applications.
My config file is as follows:
input {
beats {
port => 5044
}
jdbc {
jdbc_connection_string => "jdbc:db2://XX.XX.XX.XX:1304/DB91"
jdbc_user => "username"
jdbc_password => "password"
jdbc_driver_library => "C:\logstash-6.2.2\logstash-6.2.2\vendor\jruby\lib\jdbc\db2jcc-1.4.2.jar"
jdbc_driver_class => "com.ibm.db2.jcc.DB2Driver"
statement => "SELECT * from DBTPS29.NPSXTEI"
}
}
output {
stdout {codec => json_lines}
}
log file :
[2018-08-21T11:19:24,334][ERROR][logstash.inputs.jdbc ] Unable to connect to database. Tried 1 times {:error_message=>"Java::ComIbmDb2JccAm::SqlSyntaxErrorException: [jcc][t4][10509][13454][3.61.96] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid \r\nor was not activated for the DB2 for z/OS subsystem. If you are connecting directly to \r\nthe data server and using DB2 Connect Unlimited Edition for System z, perform the \r\nactivation step by running the activation program in the license activation kit. \r\nIf you are using any other edition of DB2 Connect, obtain the license file, \r\ndb2jcc_license_cisuz.jar, from the license activation kit, and follow the installation \r\ndirections to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968"}
[2018-08-21T11:19:24,338][ERROR][logstash.pipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_connection_string=>"jdbc:db2://xx.xx.xx.xx:1304/DB91", jdbc_user=>"username", jdbc_password=>, jdbc_driver_library=>"C:\logstash-6.2.2\logstash-6.2.2\vendor\jruby\lib\jdbc\db2jcc-1.4.2.jar", jdbc_driver_class=>"com.ibm.db2.jcc.DB2Driver", statement=>"SELECT * from DBTPS29.NPSXTEI", id=>"f63556360d1928aaaf73cf6a06df9ec2cc1f8252c016d62da5830f446521927e", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_bad95943-2146-4d84-a312-0be5db02acef", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, parameters=>{"sql_last_value"=>1970-01-01 00:00:00 UTC}, last_run_metadata_path=>"C:\Users\vipul.parikh/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: Java::ComIbmDb2JccAm::SqlSyntaxErrorException: [jcc][t4][10509][13454][3.61.96] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid
or was not activated for the DB2 for z/OS subsystem. If you are connecting directly to
the data server and using DB2 Connect Unlimited Edition for System z, perform the
activation step by running the activation program in the license activation kit.
If you are using any other edition of DB2 Connect, obtain the license file,
db2jcc_license_cisuz.jar, from the license activation kit, and follow the installation
directions to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968
Exception: Sequel::DatabaseConnectionError
Stack: com.ibm.db2.jcc.am.ed.a(com/ibm/db2/jcc/am/ed.java:676)
com.ibm.db2.jcc.am.ed.a(com/ibm/db2/jcc/am/ed.java:60)
com.ibm.db2.jcc.am.ed.a(com/ibm/db2/jcc/am/ed.java:120)
com.ibm.db2.jcc.am.jb.Qb(com/ibm/db2/jcc/am/jb.java:4339)
com.ibm.db2.jcc.am.jb.b(com/ibm/db2/jcc/am/jb.java:4248)
com.ibm.db2.jcc.t4.b.b(com/ibm/db2/jcc/t4/b.java:537)
com.ibm.db2.jcc.t4.b.a(com/ibm/db2/jcc/t4/b.java:366)
com.ibm.db2.jcc.t4.b.(com/ibm/db2/jcc/t4/b.java:305)
com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(com/ibm/db2/jcc/DB2SimpleDataSource.java:214)
com.ibm.db2.jcc.DB2Driver.connect(com/ibm/db2/jcc/DB2Driver.java:460)
java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:468)
org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:326)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.adapters.jdbc.connect(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/adapters/jdbc.rb:203)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.connection_pool.make_new(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/connection_pool.rb:126)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.connection_pool.threaded.assign_connection(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/connection_pool/threaded.rb:192)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.connection_pool.threaded.acquire(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/connection_pool/threaded.rb:133)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.connection_pool.threaded.hold(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/connection_pool/threaded.rb:90)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.database.connecting.synchronize(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/database/connecting.rb:269)
`C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.database.connecting.test_connection(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/database/connecting.rb:279)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.database.connecting.connect(C:/logstash-6.2.2/logstash-6.2.2/vendor/bundle/jruby/2.3.0/gems/sequel-5.4.0/lib/sequel/database/connecting.rb:58)
C_3a_.logstash_minus_6_dot_2_dot_2.logstash_minus_6_dot_2_dot_2.vendor.bundle.jruby.$2_dot_3_dot_0.gems.sequel_minus_5_dot_4_dot_0.lib.sequel.core.connect(C:/logstash-`

The license file name should be db2jcc_license_cisuz.jar and it should be in the same directory location as the db2jcc.jar or db2jcc4.jar. If these two are already verified to be true, then talk with your Z/OS DB2 DBA and ensure that the activation step has been performed for ...by running the activation program in the license activation kit. Your Z/OS DB2 DBA should know what that means and how to do it.

Related

db2 cloud or ODBC connection to R

Here i tried to setup my database service instance in ibm cloud DB2 and Access service credentials.
library(RODBC)
dsn_driver <- "{IBM DB2 ODBC Driver}"
dsn_database <- "bludb" # e.g. "bludb"
dsn_hostname <- "b1bc1829-6f45-4cd4-bef4-10cf081900bf.c1ogj3sd0tgtu0lqde00.databases.appdomain.cloud" # e.g "54a2f15b-5c0f-46df-8954-.databases.appdomain.cloud"
dsn_port <- "32304" # e.g. "32733"
dsn_protocol <- "TCPIP" # i.e. "TCPIP"
dsn_uid <- "xxxxxxxxx" # e.g. "zjh17769"
dsn_pwd <- "xxxxxxxxxxxxxxxx" # e.g. "zcwd4+8gbq9bm5k4"
dsn_security <- "ssl"
Then i Create a database connection
Create a connection string and connect:
conn_path <- paste("DRIVER=",dsn_driver,
";DATABASE=",dsn_database,
";HOSTNAME=",dsn_hostname,
";PORT=",dsn_port,
";PROTOCOL=",dsn_protocol,
";UID=",dsn_uid,
";PWD=",dsn_pwd,
";SECURITY=",dsn_security,
sep="")
conn <- odbcDriverConnect(conn_path)
but here i got this warning msg that the connection is field:
Warning messages:
1: In odbcDriverConnect(conn_path) :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect(conn_path) : ODBC connection failed
as i took the credentials information from the same cloud server as the below pic:
enter image description here
thank you
Hello i have question , i struggled when i try to connect the database in DB2 cloud to local R server , so i am a beginner and i found the steps for this are very mixed up so i downloaded the data bases to the DB2 cloud then i need to connect these datasets to R to do the sql functions as it requested in my course for IBM,

IBM DB2 SQL Connection Errors

I can connect to IBM DB2 inside the IBM Cloud Pak for Data, but when I try to run the exact same %sql connection it errors out. What am I missing?
'''%sql ibm_db_sa://un:pw#host:port/db?security=SSL'''
(ibm_db_dbi.Error) ibm_db_dbi::Error: [IBM][CLI Driver] SQL5005C The operation failed because the database manager failed to access either the database manager configuration file or the database configuration file.\r SQLCODE=-5005
(Background on this error at: http://sqlalche.me/e/dbapi)
Connection info needed in SQLAlchemy format, example:
postgresql://username:password#hostname/dbname
or an existing connection: dict_keys([])
IBM DB2 SQL
Try loading the package ibm_db

Oracle SQL Loader client unable to connect to server on LAN

I had a long running bash script/MySQL code to LOAD FILE into MySQL database.
I needed to convert this to Windows environment and Oracle DB. Wrote a PowerShell program and one of the lines in code uses sql loader to load files into oracle DB. The DB is in another system in LAN and I am connecting from a windows server system where I have installed the oracle full client (not just instant client) package.
Before using SQL Loader, I made sure that I am able to connect to DB from the system. The following SQL plus command works
Before using SQL Loader, I made sure that I am able to connect to DB from the system.
The following SQL plus command works
sqlplus abc/oracleabc#'"(description=(address=(host=192.168.22.44)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))"'
However I am not able to make SQL Loader work in PowerShell script.
I tried multiple command formats and connection strings
Try-1 :
sqlldr.exe abc/oracleabc#'"(description=(address=(host=192.168.22.44)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))"' control=$ctl_file_name direct='true'
Result :
LRM-00116: syntax error at 'address' following '('
Try-2:
sqlldr.exe 'abc/oracleabc#(description=(address=(host=192.168.22.44)(protocol=tcp)(port=1521))(connect_data=(sid=orcl)))' control=$ctl_file_name
Result :
LRM-00116: syntax error at 'address' following '('
Try-3
sqlldr.exe abc/oracleabc#"(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=192.168.22.44)(Port\=1521)))(CONNECT_DATA\=(SERVICE_NAME\=orcl)))" control=$ctl_file_name
Result:
SQL*Loader-704: Internal error: ulconnect:
OCIServerAttach [0]
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Try-4
sqlldr.exe userid=abc/oracleabc#ORCL control=$ctl_file_name
Result:
SQL*Loader-704: Internal error: ulconnect:
OCIServerAttach [0]
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Environmental variable ORACLE_HOME is defined in the system and points to client installation director D:\app\client\abc\product\19.0.0\client_1
tnanames.ora File :
# tnsnames.ora Network Configuration File:
D:\app\client\abc\product\19.0.0\client_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.22.44)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
sqlnet.ora File
# sqlnet.ora Network Configuration File:
D:\app\client\abc\product\19.0.0\client_1\NETWORK\ADMIN\sqlnet.ora
# Generated by Oracle configuration tools.
# This file is actually generated by netca. But if customers choose to
# install "Software Only", this file wont exist and without the native
# authentication, they will not be able to connect to the database on NT.
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
TNS Ping:
C:\Users\abc>tnsping orcL
TNS Ping Utility for 64-bit Windows: Version 19.0.0.0.0 - Production on 04-MAY-2022
08:14:07
Used parameter files:
D:\app\client\abc\product\19.0.0\client_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.22.44)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = orcl)))
OK (20 msec)
Need help in identifying the connection parameter/format issue related to SQL Loader.

PSQLEXCEPTION: Unexpected error code "55000" received from data source "FEDSER". Associated text and tokens are "This ResultSet is closed."

I am trying to do the differential data load from db2 to PostgreSQL table through InfoSphere Federation Server.
Followed below steps and got the expeption:
SQL1822N Unexpected error code "55000" received from data source "FEDSER".
Associated text and tokens are "This ResultSet is closed.".
Please find the below steps which I followed:
create wrapper jdbc
DB20000I The SQL command completed successfully.
CREATE SERVER FEDSER TYPE JDBC VERSION '12' WRAPPER JDBC OPTIONS( ADD DRIVER_PACKAGE 'E:\Sandhya\postgresql-8.1-415.jdbc3.jar', URL 'jdbc:postgresql://localhost:5432/SCOPEDB', DRIVER_CLASS 'org.postgresql.Driver', DB2_IUD_ENABLE 'Y', db2_char_blankpadded_comparison 'Y', db2_varchar_blankpadded_comparison 'Y', VARCHAR_NO_TRAILING_BLANKS 'Y', JDBC_LOG 'Y')
DB20000I The SQL command completed successfully.
CREATE USER MAPPING FOR SANAGARW SERVER FEDSER OPTIONS (REMOTE_AUTHID 'postgres',REMOTE_PASSWORD '*****')
DB20000I The SQL command completed successfully
SELECT COUNT(*) FROM "SCOPE".EMPLOYEE
SQL1822N Unexpected error code "55000" received from data source "FEDSER".
Associated text and tokens are "This ResultSet is closed.".
I am using Postgres version 12, Java version "1.8.0_241"
Please help me to resolve this issue. or once connection get created then I can only create the nickname.
Consider using Db2 11.5 instead of InfoSphere Federation Server which went out of support 2017-09-30 https://www.ibm.com/support/lifecycle/#/search?q=InfoSphere%20Federation%20Server
Db2 11.5 includes inbuilt support for PostgreSQL federation in all Db2 editions including Db2 Community Edition
https://www.ibm.com/support/pages/data-source-support-matrix-federation-bundled-db2-luw-v115

SQL0206N error when trying to connect HammerDB to DB2 using db2dsdriver.cfg file

I'm trying to generate some data for DB2 10.5 LUW using HammerDB v3.1 which is running on a Windows remote host. There is no ability to run HammerDB on the same host with DB2.
According to the HammerDB documentation I need to set up IBM Data Server Driver for ODBC and CLI.
What I did:
Downloaded and set up the driver on HammerDB host - v10.5fp10_ntx64_odbc_cli.zip as described here
Configure db2dsdriver.cfg file
<configuration>
<dsncollection>
<dsn alias="TPCC" name="<my database name>" host="<my host name>" port="50000"/>
<!-- Long aliases are supported -->
<dsn alias="longaliasname2" name="name2" host="server2.net1.com" port="55551">
<parameter name="Authentication" value="SERVER_ENCRYPT"/>
</dsn>
</dsncollection>
<databases>
<database name="<my database name>" host="<my host name>" port="50000">
<parameter name="CurrentSchema" value="OWNER1"/>
.......
Add environment variable DB2DSDRIVER_CFG_PATH
set DB2DSDRIVER_CFG_PATH=C:\ProgramData\IBM\DB2\C_IBMDB2_CLIDRIVER_clidriver\cfg
Run HammerDB GUI, try to build a schema and receive
Error in Virtual User 1: [IBM][CLI Driver][DB2/LINUXX8664] SQL0206N "GLOBAL_VAR1" is not valid in the context where it is used. SQLSTATE=42703```
This error is happening because the db2dsdriver.cfg has excess information for your DSN on a Db2-client-node.
To recover, you can either rename and recreate your db2dsdriver.cfg/db2cli.ini files, or you can can edit the db2dsdriver.cfg file and remove the following stanza where it occurs for your DSN / database (take a backup as a precaution):
<sessionglobalvariables>
<parameter name="global_var1" value="abc"/>
</sessionglobalvariables>
I usually discard the default db2dsdriver.cfg/db2cli.ini, and use a script to populate them. This is possible by using the command line tool "db2cli", which has a variety of command lines parameters to let you write the cfg file stanzas for both DSN and databases. Documentation here.