Connecting to Oracle PDB via ODBC - oracle

I have a LOCAL Oracle 19c database. I am trying to get ADO to connect to it. The first step is to get ODBC working. I have one PDB container called orclpdb, which is what I want to use. I can connect from SQL*Plus...
Y:\INSTALL_UNZIP\bin\sqlplus.exe acs/<Password>#localhost:1521/orclpdb
I go into the 64-bit ODBC Administrator, and had to fight a little bit (adding OCI_LIB32 and TNS_ADMIN paths), but finally got the ODBC Admin tool to connect, but ONLY to the root/system database. My root question is 'How do I get ODBC administrator to connect to a specific container DB?
Within the ODBC Administrator, the TNS Service Name field dropdown only shows ORCL, not orclpdb. Again, I can connect using ORCL, but as system/.
UPDATE: Due to issues such as this, I switched most apps to Devart's Oracle Data Access components to Delphi. They have a DIRECT mode, which does not need SQL*Net or TNS stuff
.

Make sure your TNS_ADMIN/tnsnames.ora file has an entry for the PDB (orclpdb).

Related

How to connect to Oracle 21c in Oracle Cloud from DataGrip

I have created an Autonomous Transaction Processing database in Oracle Cloud. There are no ready-for-use JDBC links around, but there are "wallets". There is an instance wallet and regional wallet. Oracle says one of them, preferably instance wallet, should be used to connect to this DB instance.
A wallet is a ZIP file with a dozen of files inside. I've downloaded an instance wallet and unzipped it. Now I'm trying to connect DataGrip to this instance.
There is a TNS connection type in DataGrip and there is a famous tnsnames.ora in the wallet, so I guess I should use them. TNS connection type accepts a TNSADMIN parameter, which, I guess, is a directory of that wallet. tnsnames.ora from the wallet lists a few service names, AFAIU they differ by their priority, e.g. one for low-priority queries, another for medium-priority and one for the highest priorities question. I'm OK with medium priority, so I did this:
As you see, I'm getting an error:
[08006][17002] IO Error: The Network Adapter could not establish the connection
SSO KeyStore not available.
I've googled around, but this topic seems to be complicated. Oracle has a lot of connection parameters with certificates involved in the connection process, and I'm really new and I just want to connect to this instance. Why it should be so complicated? Can I use this wallet directly in DataGrip?
It seems that I've did everything correctly and the only problem is actually the driver version.
As of today, 2021-02-02, the latest available Oracle driver version in DataGrip is 19.8.0.0:
To fix the issue I've just created another Oracle driver in DataGrip and manually provided the latest JARs:
Go to the Oracle Database 21c (21.1) JDBC Driver & UCP Downloads
Download the ZIPped JDBC driver and companion JARs corresponding to your Java version: 8 or 11. Or just download the version for Java 8 (ojdbc8-full.tar.gz). It should work with any modern Java.
Create new subdirectory in the DataGrip's drivers directory for you driver. Something like ~/.config/JetBrains/DataGrip2020.3/jdbc-drivers/Oracle/21.1 for Linix.
Unzip the driver in that directory.
Configure new driver in DataGrip. Just clone the existing Oracle driver and replace the "Driver Files" with the ones from the ZIP.
Use this new driver to connect to the instance:
DataGrip 2021.1 provides Oracle JDBC Driver 21.1.0.0 with all required jar files.
Also, read DataGrip article about connection to Oracle using wallets.

Export Database connection to Oracle Developer

I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.

IIS site not connecting to Oracle database

I have a server with IIS that hosts web sites.
Some of those web sites (Silverlight) must connect to an Oracle Database to perform queries via OleDb, but they cannot.
Here are the results of what I tested :
'msdaora' provider is not registered on local machine when I run it in the web site
ORA-01019: unable to allocate memory in the user side (when I try to connect with a test console program without administrator status)
Connection OK (with the same test console program WITH administrator status)
ORA-12154: TNS:could not resolve the connect identifier specified when trying to switch to another method of connection (from OleDb to Oracle.ManagedDataAccess.Client)
I went through countless info about these kind of errors but I couldn't find any working solution.
Here is what I tested :
giving "create global objects" right to the relevant users (no change at all)
installing several Oracle clients one after another. Best result is with 10.2 client 64b (where my test program can connect while having administrator rights). The install is clean (no several Oracle folders nor several Oracle environment variables at the same time)
disabling warnings concerning the administrator elevation (ie no confirmation pop up during elevation) : no change at all
checking RAM usage (plenty of memory under the foot)
Additional infos :
The connection string is
Provider=msdaora;Data Source=HOSTNAME;User Id=USER;Password=PASSWORD
Same connection string used with OleDb and Oracle.ManagedDataAccess.Client.
The tsnames.ora file exists (and works, as show my succesful attempt with the administrator test program)
It's working on an older web server, but there are too much differences for me to find any meaningful one (different Windows, 32/64b, different IIS versions, different Oracle client)
Any idea ?
There are several points:
Microsoft msdaora provider for OLE DB is deprecated for ages. You should prefer the Oracle Provider OraOLEDB.Oracle.
Oracle Client and OLE DB provider and IIS application have to have the same architecture, i.e. all must be either 32 bit or 64 bit, you cannot mix them. (ancient msdaora is not available for 64 bit). However, ODP.NET Managed Driver (Oracle.ManagedDataAccess) works for both 32 bit and 64 bit.
When you use ODP.NET Managed Driver then Provider=MSDAORA is not needed in ConnectionString. I assume such attributes is ignored or you just missed to mention it.
Version of Oracle Client and OLE DB provider must match (even minor version). Due to COM limitation you cannot install more than one OLE DB provider for 32 bit and 64 bit each.
Search pattern for tnsnames.ora file in OLE DB is different to search pattern in ODP.NET Managed Driver. Verify following items:
OLE DB reads your Registry for TNS_ADMIN value, the ODP.NET Managed Driver does not.
ODP.NET Managed Driver uses your .NET config file (i.e. web.config, machine.config) to determine location of tnsnames.ora file, the OLE DB does not.
According documentation ODP.NET Managed Driver does take into account the TNS_ADMIN Environment variable and folder %ORACLE_HOME%\network\admin. However, according to my tests it does anyway.
Regarding connection failure is depending on "Rus as Administrator" check permissions of your Oracle installation folder.

Microdoft ODBC for oracle defined source not being picked up by application and throwing SQLConnect() failed

I have a 32 bit .net exe (on a win 7 machine) which runs and writes data to an oracle db. For this application to access the DB I have created a ODBC source (Microsoft ODBC for Oracle) under System DSN of odbcad32.exe from c:\windows\syswow64.
Instead of picking this source the application is picking a default connection source for the user. Please see below. (from sqlnet.ORA)
Fatal NI connect error 12560, connecting to:
(DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCL)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCL)(CID=(PROGRAM=D:\Projects\abc\Web\dll\reader.exe)(HOST=abc-43DGMX1)(USER=NGolia))))
The application (exe) is obviously not able to connect to the correct DB and throws a
ERROR SQLConnect() Failed.
Could anyone help let me know what could be missing? Am I missing any environment variables or
Are you able to test the connection in the Oracle ODBC Driver Configuration? If the application is 32bit, you're using the correct odbcad32.exe. I would check your tnsnames.ora in your $ORACLE_HOME and verify the database information looks correct there.

JBoss application cannot make XA connection to Oracle 11g

I've been working on several JBoss applications where I have everything running on my laptop (Windows XP) including an Oracle database (11g Enterprise Edition). Everything works fine on the laptop.
Now I'm setting up a new, faster machine (running Windows 7 Professional) and the non-XA JBoss apps run fine but the apps requiring an XA connection cannot connect to Oracle. I'm pretty sure it is a problem with my new Oracle installation because I can point the apps to an external Oracle server and they work, but they fail to connect when pointing them my local Oracle database.
I've done a lot of google searches and the only information I can find is that I need to run the script $ORACLE_HOME/rdbms/admin/xaview.sql to create some XA views and I need to grant the following permissions to the user:
GRANT SELECT ON sys.dba_pending_transactions TO <user>;
GRANT SELECT ON sys.pending_trans$ TO <user>;
GRANT SELECT ON sys.dba_2pc_pending TO <user>;
GRANT EXECUTE ON sys.dbms_xa TO <user>;
But after doing all that, I still cannot get the apps to connect.
This is the exception I'm getting:
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception:
The Network Adapter could not establish the connection) at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAMangedConnectionFactory.java:144) at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventLisener(InternalManagedConnectionPool.java:577) at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:262) at
org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500) at
org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347) at
org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330) at
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402) at
org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849) at
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:90) at
org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46) at
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
I know this isn't really a programming question, but I was hoping someone had seen this before. Any help would be much appreciated.
I was able to resolve this issue by ensuring that the host name and domain name settings in the LISTENER.ORA file and in the TNSNAMES.ORA file matched. For example, if one had HOST = localhost and the other had HOST = myhost.xyz.com then it would cause problems for XA but not for normal Java JDBC connections. My theory is that some part of the XA stack needed to make an OCI connection that read the TNSNAMES.ORA file but then could not connect because of a mismatch with the Listener configuration. Normal Java JDBC connections don't care about the TNSNAMES.ORA file as they make a direct connection to the listener with their own configuration settings.
I also had to rename some folders from xxx_localhost_yyy to xxx_myhost_yyy to get the Enterprise Manager to work.
To get TOAD to work I had to install the 32 bit client as it will not work with the 64 bit client and I had to configure it's ORACLE_HOME variable in the Windows registry under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oracle. Apparently Wow6432Node is a special place in the Windows registry for defining values that only 32 bit applications will see.
Anyway, I'm relieved to have it all working.
Well, can you connect using a sql client to this database ?

Resources