Can I see the connection string in DBeaver and copy it to make a connection to DB2 in Python? [duplicate] - python-3.x

I have a running DBeaver connection to a DB2 database and now I would like to connect also in Python with the DB2 database securely over SSL. As authenticating I would like to use my windows account instead of giving a PW and UserID, to do so in DBeaver I changed:
javax.net.ssl.keyStoreType = Windows-ROOT
javax.net.ssl.trustStoreType = Windows-MY
Is this also possible with the Python connection?
I tried the following to set up the connection:
import ibm_db
connID = ibm_db.connect('DRIVER={IBM DB2 ODBC DRIVER};'
'DATABASE=XXXX;'
'HOSTNAME=XXXXYYY.net;'
'PORT=9797;'
'PROTOCOL=TCPIP;'
'SECURITY=ssl;'
'SSLSERVERCERTIFICATE=C:/Users/..../cert.cer;'
, '', '')
if connID is None:
print("\nERROR: Unable to connect.")
exit(-1)
print("Connected!")
I get the following error:
SQLCODE=-30082][CLI Driver] SQL30082N Security processing failed with reason "17" ("UNSUPPORTED FUNCTION"). SQLSTATE=08001
Some details:
M:\>"C:\Users\.conda\pkgs\ibm_db-3.0.1-py37hfa6e2cd_1\Lib\site-packages\clidriver\bin\db2level.exe"
DB21085I This instance or install (instance name, where applicable: "*") uses
"64" bits and DB2 code release "SQL11013" with level identifier "0204010F".
Informational tokens are "DB2 v11.1.3031.295", "s1804271300",
"DYN1804271300WIN64", and Fix Pack "3a".
Product is installed at
"C:\Users\.conda\pkgs\ibm_db-3.0.1-py37hfa6e2cd_1\Lib\site-packages\cli
driver" with DB2 Copy Name "IBM Data Server Driver For ODBC and CLI".
I'm using:
Python version 2.7.17
Ibm_db version 3.0.1

Related

ibm_db for nodejs: using TCP/IP works fine but using SSL reports SQL30081N A communication error "selectForConnectTimeout"

In a Node app with ibm_db, I am trying to connect to Db2 Warehouse on Cloud using ssl connection string.
On CentOS 7.8, using SSL connection string as below works fine.
var connStr = "DATABASE=BLUDB;HOSTNAME=dashdb-xxxxxxxxxxxx.xxxxx.xxx.bluemix.net;PORT=50001;PROTOCOL=TCPIP;UID=XXXXXXXXX;PWD=XXXXXXXXXXX;Security=SSL"
However, on RHEL 7.2, using SSL connection string does not work, SQL30081N is reported. It is same source code working on CentOS 7.8.
[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: "XXX.XX.XXX.XXX".
Communication function detecting the error: "selectForConnectTimeout".
Protocol specific error code(s): "115", "*", "*". SQLSTATE=08001\n
As a test, changing SSL connection string to TCP/IP connection string as below, it works on RHEL 7.2.
var connStr = "DATABASE=BLUDB;HOSTNAME=dashdb-xxxxxxxxxxxx.xxxxx.xxx.bluemix.net;UID=XXXXXXXXX;PWD=XXXXXXXXXXX;PORT=50000;PROTOCOL=TCPIP";
On each environment, installed the latest IBM ODBC and CLI Driver via npm install ibm_db.
I think the certificate file for ssl connection is bundled with the driver package and will be used for connections, so ssl configuration does not required manually.
Or, would I need to configure anything else for using SSL on RHEL 7.2 ?

Pyodbc connection error encoding name too long

I use pyodbc to connect into a postgresql server over an ssh connection, the ssh connection goes well, but when I try to connect to the bd its returns a strange error:
encoding name too long
I don't know how to handle this!
Conn string - SERVER=127.0.0.1;DATABASE=xxxxx_core_xxx;UID=xxxxty;PWD=####$;PORT=12345;DRIVER={DRIVER_Postgresql};
odbc.ini
[DRIVER_Postgresql]
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
odbcinst.ini

Rattle 5.1 ODBC connection issue

I've tried the ODBC connection in Rattle 5.1 many times with the same error.
Error in sqlTables(crs$odbc) :
first argument is not an open RODBC channel
In addition: Warning messages:
1: In RODBC::odbcDriverConnect("DSN=ORCL", believeNRows = TRUE) :
[RODBC] ERROR: state 28000, code 1005, message [Oracle][ODBC][Ora]ORA-01005: null password given; logon denied
2: In RODBC::odbcDriverConnect("DSN=ORCL", believeNRows = TRUE) :
ODBC connection failed
I've even hard-coded the password in OCBC.ini but it still doesn't work.
RODM_open_dbms_connection with the same DSN works fine.
I figured this out. I downloaded R 3.4.3 on another laptop and the ODBC connection works. It's R 3.5.0 that it has problem with. Looks like Rattle 5.1.0 may not be compatible with R 3.5.0 yet.

Error while making connection on oracle sql developer using linux OS

I am trying to make a new connection on oracle sqldeveloper as sysdba and when i hit test or connect i got this error message:
Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection
The default port is 1521, but 1522 is often common.
Check if the database is up. database will not be up causing this issue.
or Check if you are able to connect using sqlplus

Need Help for connecting MSSQL SERVER From Linux(ubuntu)

I just installed the ODBC driver in the Ubuntu, but still I am facing issues while connecting the database from Perl. Here is the description on what I have done in my machine.
I installed the MSSQL Driver and Unix ODBC from easysoft website. The path details in my machine follows:
ODBC Installed Path:- user/local/easysoft/unixodbc
Data Source and Driver path: user/local/etc Sample Code:
#!/usr/bin/perl
use strict;
use DBI;
my $dsn="DBI:ODBC:DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name";
my $dbh = DBI->connect($dsn, "username", "password" ,{AutoCommit => 1} )
or die DBI::errstr;
Error:
DBI connect('DRIVER={SQL Server};Server=xxx.xxx.xxx.xxx,1433;database=DB_name','username',...) failed: unixODBCDriver Manager Can't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5
unixODBCDriver ManagerCan't open lib 'SQL Server' : file not found (SQL-01000) at sample.pl line 5.
DRIVER={SQL Server}
You code is attepmting to connect to a [SQL Server] driver in your odbcinst.ini file. However if you are using the Easysoft ODBC-SQL Server Driver you will need to use :-
Driver={Easysoft ODBC-SQL Server}

Resources