Oracle Instant with LDAP gives error ORA-12154 - database

Help connecting to LDAP db w/ Oracle Instant Client
Test environment: a Mac connecting to an Oracle 12c database
Client software: Oracle Instant Client
Oracle DB name (example): oid.db.example.com
DB alias: mydb
DP port: 4000
DB connectivity: LDAP via OID
Service Name: myservice
LDAP stuff: cn=utility
The LDAP string that works in Oracle SQL Developer:
jdbc:oracle:thin:#ldap://oid.db.example.com:4000/myservice,cn=utility
[Environment Variables]
export ORACLE_HOME=/Applications/Oracle_Instant
export LD_LIBRARY_PATH=/Applications/Oracle_Instant
export TNS_ADMIN=/Applications/Oracle_Instant/network/admin
export ORACLE_ADMIN=${TNS_ADMIN}
## Settings in network/admin/ ##
[ldap.ora]
DIRECTORY_SERVER_TYPE=oid
DIRECTORY_SERVERS=(oid.db.example.com:4000)
DEFAULT_ADMIN_CONTEXT="cn=utility"
[sqlnet.ora]
names.directory_path = (LDAP, HOSTNAME)
names.default_domain = WORLD
trace_level_client = OFF
sqlnet.expire_time = 30
[tnsnames.ora]
mydb = (description=
(address_list=
(address = (protocol = TCP)(host = oid.db.example.com)(port = 4000))
)
(connect_data =
(SID=myservice
(SERVER = DEDICATED)
)
Command I tested with, but got an error:
./sqlplus myusername/mypassword#mydb
Error I got:
./sqlplus username/password#mydb
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Nov 18 19:01:23 2019
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified

Related

QT unable to connect to mssql server from qt application in ubuntu

Unable to connect to mssql server from qt application in ubuntu 20.04
Sql server located in windows 7
The connection is definitely present, because it was possible to connect through DDbeaver.
Can anyone help me in this situation?
Code:
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3");
db.setConnectOptions();
QString serverName = "566***";
QString ipName = "tcp:192.168.144.101,1433";
QString dbName = "St***";
QString connectionString = QString("DRIVER={ODBC Driver 18 for SQL Server};Server=%1;Database=%2;").arg(ipName).arg(dbName);
db.setDatabaseName(connectionString);
db.setUserName("sa");
db.setPassword("top123TOP");
if (db.open())
{
qDebug() << "Correct connection";
}
else
{
QString error = db.lastError().text();
qDebug() << error;
}
otuput is:
"[Microsoft][ODBC Driver 18 for SQL Server]TCP Provider: Error code 0x2746 [Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection QODBC3: Unable to connect"
odbcinst.ini
[ODBC Driver 18 for SQL Server]
Description=Microsoft ODBC Driver 18 for SQL Server
Driver=/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.0.so.1.1
the following solution helped:
from:https://github.com/microsoft/msphpsql/issues/1112
This was helpful.
Ubuntu 20.04 PHP 7.4 using the 19.10 drivers for sqlsrv
We have a real old SQL server out there . The SQL Server show's version 10.50.2550.0, i think it's SQL Server 2008 R2. I had to use TLSv1 to connect to the server. I also had to do a "systemctl restart apache2" to get it to take affect. TLSv1.1 did not work with my MSSQL server version.
Error message: Connection failed: SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol]Database Connection Error
edit: /etc/ssl/openssl.cnf
1st line in the file added
openssl_conf = default_conf
End of file added
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
MinProtocol = TLSv1
CipherString = DEFAULT#SECLEVEL=1
Not 100% sure why i had to restart apache2 for it to take effect, but I had to.
systemctl restart apache2
reloaded the page and it works

ORA-12162: TNS:net service name is incorrectly specified

I'm trying to monitor my oracle db with zabbix by ODBC. My database version is 11.2 and I have the DB name, port, login and the password.
What I did until now is:
1- installed oracle instant client-basic, devel, sqlplus and odbc (all 11.2 version)
2- installed unixodbc and unix odbc-devel
and I configured some files:
/etc/oracle/tnsnames.ora
MY.DB.NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = {i put my db host ip}) (PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = MY.DB.NAME)
)
)
/etc/odbc.ini
[MY.DB.NAME]
Driver = OracleDriver
Server = {my db host ip}
User = dbuser
Password = db123
Port= 1521
Database = MY.DB.NAME
/etc/odbcinst.ini
[OracleDriver]
Description = Oracle ODBC driver for Oracle 11g
Driver=/usr/lib/oracle/11.2/client64/lib/libsqora.so.11.1
And I did some exports:
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/lib;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME;
export TNS_ADMIN=/etc/oracle;
I want to test my connection with isql command, but when I try:
isql MY.DB.NAME
I receive this error message. I've never do this before, I followed many tutorials but I'm lost

How to solve the user connection problem when using the framework pyodbc in Ubuntu 16.04 machine?

Solved!!!
I am trying to connect with a local SQL Server database using the Python framework 'pyodbc' in an Ubuntu machine. But I get over and over the same error.
As background I have to add that I first createn locally a database with the 'sqlcmd' application and it works good in the terminal. I can access by this way.
sqlcmd -S 127.0.0.1 -U SA
But when I try access by Python scrip and I get the error.
Here is my code:
import pyodbc
details = {
'server' : '127.0.0.1',
'database' : 'testDB',
'username' : 'SA',
'password' : 'password'
}
connect_string = 'DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={server};PORT=1443; DATABASE={database};UID={username};PWD={password})'.format(**details)
connection = pyodbc.connect(connect_string)
print(connection)
This is a simple code to star working with the framework, however I got the next error output in jupyter notebook:
InterfaceError: ('28000', "[28000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'SA'. (18456) (SQLDriverConnect)")
Solved!!
driver = "ODBC Driver 17 for SQL Server"
server = "127.0.0.1"
database = "testDB"
username = "sa"
password = "pwd"
print ("'DRIVER={" + str (driver) + "};SERVER=" + str (server) + ";DATABASE=" + str (database) + ";UID=" + str (username) + ";PWD=" + str (password) + "'")
import pyodbc
conn = pyodbc.connect ('DRIVER={ODBC Driver 17 for SQL Server};SERVER=127.0.0.1;DATABASE=testDB;UID=sa;PWD=pwd')
getcon = conn.cursor ()
print ("Connected to Database!")
Now with this syntax works!!

Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"

while trying to connect to remort mssql server by command
tsql -S SQLEXPRESS -U sa
passwod :sa
it throws error as
Error 20009 (severity 9):Unable to connect: Adaptive Server is unavailable or does not exist OS error 111, "Connection refused"
Steps i followed
/etc/freetds/freetdsconf.conf
[SQLEXPRESS]
host = 192.168.1.9
port = 1433
tds version = 8.0
client charset = UTF-8
/etc/odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver =/usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup =/usr/lib/i386-linux-gnu/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
etc/odbc.ini
[SQLEXPRESS]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = 192.168.1.9
Database = cakephp_results
Port = 1433
UID = sa
PWD = sa
ReadOnly = No
In your odbc.ini file change 'Servername = ' to 'Server = '. Then remove the UID, PWD and ReadOnly lines from that file temporarily. You may want to remove them altogether and pass in the credentials from your application.
Then, be sure that your MSSQL DB is allowing connections through port 1433, that SQL Server is not blocking the incoming server's IP address, and that you have the correct password.
Also, if that doesn't work, review these troubleshooting instructions:

FreeTDS - tsql connects, isql fails

I'm trying to connect to a database on my host machine (windows xp, sql server 05). My guest machine is Ubuntu 10.04. I can connect and execute commands with tsql, but isql fails. Below are my config files and error messages.
freetds.conf
text size = 64512
[SQLEXPRESS]
host = 192.168.163.1
port = 1433
tds version = 7.0
odbcinst.ini
[FreeTDS]
Description = TDS driver (Sybase/MS SQL)
Driver = /usr/lib/odbc/libtdsodbc.so
Setup = /usr/lib/odbc/libtdsS.so
CPTimeout =
CPReuse =
FileUsage = 1
odbc.ini
[SQLEXPRESS]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Servername = 192.168.163.1
Database = SCOPE_Peel
Port = 1433
UID = sa
PWD = test1234
ReadOnly = No
tsql:
tsql -S SQLEXPRESS -U sa
#success
isql:
isql SQLEXPRESS sa test1234 -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect
The issue was this line in odbc.ini
Servername = 192.168.163.1
It should have been SQLEXPRESS which I think points to the name of the server configured in freetds.conf

Resources