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}
Related
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 ?
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
I am new to Oracle. I'm not able to connect in Node with Oracle; getting some path issue:
undefined-dbConnectionFactory: Error while cretaing the Idr DB Client, Error: Error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "C:\APPS\OraClient\OraHome_12c\oci.dll is not the correct architecture
But my instant-client is at another location, I already set its path in the PATH variable: D:\Users\instantclient\instantclient_19_5. I already set the same path into plSQL. I am able to connect PLSQL but not with my code.
I am getting
cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred error while connecting oracle from python.
I have installed python 3.7.0 and instantclient_11_2.
Below are the process i am doing,
import cx_Oracle
dsn_tns = cx_Oracle.makedsn( '<ip>', 1521, service_name = '<given service name>')
connection = cx_Oracle.connect('user', 'pwd', dsn_tns)
I have set system veriable PATH where oci.dll is present.
What could be wrong?
Try:
connection = cx_Oracle.connect('user', 'pwd', cx_Oracle.makedsn( '<ip>', '1521',None,'<given service name>'))
Looks the same but works different in my ubuntu server.
Also make sure to put the port between ' '
You should also be able to use the following connect string if the database resides on the same machine:
connection = cx_Oracle.connect('user/pwd#localhost/service_name')
Note that a service_name value is required. You can't use the empty string!
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