pyodbc Driver keyword syntax error - syntax

My conn_str that is passed into pyodbc.connect(conn_str) is:
conn_str = str("DRIVER={{ODBC Driver 13 for SQL Server}};" +
"server=...;database=...;" + "APP=Entity Mapping
Lookup;UID=svc_infra_jobs;PWD=...").
The =... next to server and database actually contain names, that is not the problem here.
When i try to do: temp = pyodbc.connect(conn_str), I get the error:
pyodbc.Error: ('IM012', '[IM012] [Microsoft][ODBC Driver Manager]
DRIVER keyword syntax error (0) (SQLDriverConnect)')
I have no idea what is wrong with my DRIVER keyword.

I know this is old but figured out that for some driver managers the DSN name length can't exceed 32 characters.
https://community.microstrategy.com/s/article/KB44110-quot-Data-source-name-is-longer-than-32-characters-quot?language=en_US

Related

JDBC EZConnect URL: Invalid number format for port number when specifying Protocol

When specifying a JDBC EZConnect URL to include the Protocol, for example:
jdbc:oracle:thin:#tcps://example1.com:1522/my_service_name
jdbc:oracle:thin:#tcp://example1.com:1522/my_service_name
I am getting the error "Status : Failure - Test Failed: IO Error: Invalid number format for port number"
I am following the example page XXX of the Oracle 19c JDBC Developers Guide (http://ora-srv.wlv.ac.uk/oracle19c_doc/jjdbc/jdbc-developers-guide.pdf)
Does anyone have any input into why this error is occurring ?
Thanks
Andrew

What are the best practices for troubleshooting Heterogeneous ODBC connections?

I am trying to establish a heterogeneous ODBC connection from an Oracle 21c XE database to a Progress OpenEdge 11.7 database. I have installed a 32 bit ODBC driver on the Windows 2019 server where the 21c XE DB resides. I have set up an ODBC System DSN, tested it and it works.
I created a initTIMEDATA.ora file in the C:\app\Administrator\product\21c\homes\OraDB21Home1\hs\admin folder.
It contains;
HS_FDS_CONNECT_INFO = TimeData
HS_FDS_TRACE_LEVEL = 4
HS_FDS_TRACE_FILE_NAME = TimeData.trc
Where TimeData matches the ODBC System DSN name.
I modified the listener.ora adding;
(SID_DESC=
(SID_NAME=TimeData)
(ORACLE_HOME=C:\app\Administrator\product\21c\dbhomeXE)
(PROGRAM=C:\app\Administrator\product\21c\dbhomeXE\bin\dg4odbc)
(ENVS = LD_LIBRARY_PATH=C:\Progressx86\OpenEdge\lib:C:\app\Administrator\product\21c\dbhomeXE\bin)
)
I modified my tnsnames.ora file adding;
TIMEDATA=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=10.254.10.41)
(PORT=4621)
)
(CONNECT_DATA=
(SID=TimeData))
(HS=OK))
I created a DBLink like;
CREATE PUBLIC DATABASE LINK time_data_link CONNECT TO "sqluser" IDENTIFIED BY "myPassword" USING 'TIMEDATA';
After restarting everything (DB, Listener...) the listener shows;
Service "TimeData" has 1 instance(s).
Instance "TimeData", status UNKNOWN, has 1 handler(s) for this service...
When I try to run a query;
SELECT * FROM employee_view#time_data_link;
I get;
ORA-28545: error diagnosed by Net8 when connecting to an agent
Unable to retrieve text of NETWORK/NCR message 65535
ORA-02063: preceding 2 lines from TIME_DATA_LINK
28545. 0000 - "error diagnosed by Net8 when connecting to an agent"
*Cause: An attempt to call an external procedure or to issue SQL
to a non-Oracle system on a Heterogeneous Services database link
failed at connection initialization. The error diagnosed
by Net8 NCR software is reported separately.
*Action: Refer to the Net8 NCRO error message. If this isn't clear,
check connection administrative setup in tnsnames.ora
and listener.ora for the service associated with the
Heterogeneous Services database link being used, or with
'extproc_connection_data' for an external procedure call.
Error at Line: 1 Column: 29
I see no errors in the listener.log, I cannot find TimeData.trc. In poking around the DB trace files I found a trace file related with multiple copies of;
HS connect: nscall returned status ffffffff (-1)
ns main err code: 12569
ns (2) err code: 0
nt main err code: 0
nt (2) err code: 0
nt OS err code: 0
*** 2022-04-03T17:01:07.758909-04:00 (XEPDB1(3))
HS: Unable to establish RPC connection to HS Agent...
HS: ... Agent SID = (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.254.10.41)(PORT=4621))(CONNECT_DATA=(SID=TimeData))), NCR error = 65535 Unable to retrieve text of NETWORK/NCR message 65535
I have reached the end of my troubleshooting skills and hope someone else may be able to point me in the right direction.
I had two problems.
The TNSNAMES.ORA file needed to point to the Oracle DB server, running on localhost in my case. Once I changed this, the error changed to
Error;
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application {IM014}
New TNSNAMES.ORA;
TIMEDATA=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=localhost)
(PORT=1521)
)
(CONNECT_DATA=
(SID=TimeData))
(HS=OK))
Once I saw this error it became apparent I needed the 64 bit version of the ODBC driver which I acquired.
After making these changes everything seems to work.

Getting System error code of 126 in Informatica

The setup routine for the BMC ODBC for Oracle(default) Odbc driver couldn't be loaded due to system error 126. The specified module could not be found.
I'm getting this error in imformatica 9.5.1
Can anyone suggest any solution..

What's the meaning of: "java.sql.SQLRecoverableException: I/O-Error: Unknown host specified" if TNS-alias specified

Using Oracle JDBC driver with TNS-alias instead of host:port:SID a'la
jdbc:oracle:thin:#TNS_ALIAS
you may get this error message
java.sql.SQLRecoverableException: I/O-Error: Unknown host specified
while calling
java.sql.DriverManager.getConnection
But there is no problem with the hostname specified by TNS-alias.
Sadly this error message does not point to the real reason:
The error occurs if driver cannot find the tnsnames.ora config file.
Solution
You have to ensure that system-property "oracle.net.tns_admin" is set before connecting and points to the directory containing the tnsnames.ora.

gdal incorrectly quoted string literal Oracle OCI

I updated to gdal version 2.
Now i get to error if i want get data from my Oracle Database.
ogrinfo -ro OCI:database/passwd -sql "SELECT COUNT(*) FROM tablename"
The Error i get is: Incorrectly quoted string literal.
with the old gdal version 1.xx it works correctly
I think the problem is the oci.dll at the gdalplugins. Has anybody some idea
After waiting a little bit i get the error
ORA-12154: TNS:could not resolve the connect identifier
It doesn't know why, because with the old gdal version it had worked
SQL quoting is strict in 2.x that 1.x, see:
https://trac.osgeo.org/gdal/browser/trunk/gdal/MIGRATION_GUIDE.TXT#L123

Resources