What is the correct JDBC URL syntax if using Oracle wallets?

There are 2 URL syntaxes, the old syntax that will only work with SID, and the new one with the name of the Oracle service.
Old syntax

jdbc:oracle:thin:@[HOST][:PORT]:SID 

New syntax

 jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE 

What is the correct JDBC URL syntax if using Oracle wallets ?
The following URL syntax should be used according to this article :

 jdbc:oracle:thin:/@db_alias 

But as I see, the following url works too:

 jdbc:oracle:thin:@db_alias 

Which of these syntaxes is correct?

+8
source share
1 answer

When you use Oracle Wallet with a JDBC string, both syntaxes are allowed if your "db_alias" is installed in your Wallet store, obviously.

Now, regarding the use of SQL * Plus with Oracle Wallet, the only format allowed in Oracle Wallet is:

 /@db_alias 

By the way, this article that you referenced (and others ) indicates that you can only connect using JDBC if you are using OCI drivers and not a thin client. Usually this / was due to the fact that Java did not know the Oracle TNS and SQLNET files. This is actually not the case; you can connect using the thin JDBC driver with the latest Oracle Client and JDBC drivers, but this requires some configuration. See http://tech.shopzilla.com/2011/09/oracle-wallet-with-thin-driver-with-connection-pool-with-database-timeouts/ for information on this and below for a brief summary.

Using Oracle Wallet with JDBC Thin Driver

  • Set up Oracle Wallet as usual (which comes with the Oracle Database Client) by creating the corresponding entries in your tnsnames.ora and sqlnet.ora files, as well as the account in your wallet
  • Add the following JARs to your Java path. You must get them from the Oracle 11g client and can be found in the "jdbc" and / or "jlib" directories where the client is installed
    • Oracle JDBC driver - ojdbc6.jar
    • Oracle Wallet - oraclepki.jar
    • Oracle Security Certificates - osdt_cert.jar
    • Oracle Security Core - osdt_core.jar
  • Launch a Java application with the following system properties, pointing to the corresponding TNS and wallet directories:
    • -Doracle.net.tns_admin=C:\myTNSdir
    • -Doracle.net.wallet_location=C:\mywalletdir
  • Then you can use the thin JDBC connection string in your application like this: jdbc:oracle:thin:/@MY_WALLET_DB_ENTRY
+22
source

All Articles