开发者

What is correct JDBC URL syntax if Oracle wallets are used?

There are 2 URL syntax, old syntax which will o开发者_Python百科nly work with SID and the new one with Oracle service name.

Old syntax

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

New syntax

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

What is correct JDBC URL syntax if Oracle wallets are used?

According to this article following URL syntax should be used:

jdbc:oracle:thin:/@db_alias  

But as I can see following URL works too:

jdbc:oracle:thin:@db_alias

Which of these syntaxes are correct?


When you are using Oracle Wallet with a JDBC string, both syntax's are allowed, so long as your "db_alias" is setup in your Wallet store obviously.

Now, as far as using SQL*Plus with Oracle Wallet, the only format allowed with Oracle Wallet is:

/@db_alias

By the way, that article you referenced (and others) specifies you can only connect using JDBC if you use the OCI drivers, and not the thin client. This is/was typically because Java had no knowledge of the Oracle TNS and SQLNET files. This is in fact not true; you can connect using the JDBC thin driver with the latest Oracle Client & JDBC Drivers, but it just requires some setup. See http://tech.shopzilla.com/2011/09/oracle-wallet-with-thin-driver-with-connection-pool-with-database-timeouts/ for info on that, and below for a short summary.

Using Oracle Wallet with JDBC Thin Driver

  1. Configure Oracle Wallet as usual (which comes with the Oracle Database Client), creating the appropriate entries in your tnsnames.ora and sqlnet.ora files as well as the credential entry in your wallet
  2. Add the following JARs to your Java classpath. You should get these from the Oracle 11g client, and they can be found in the "jdbc" and/or "jlib" directories of where the client install is
    • Oracle JDBC Driver - ojdbc6.jar
    • Oracle Wallet - oraclepki.jar
    • Oracle Security Certs - osdt_cert.jar
    • Oracle Security Core - osdt_core.jar
  3. Start your Java application with the following system properties, pointing at your respective TNS and wallet directories:
    • -Doracle.net.tns_admin=C:\myTNSdir
    • -Doracle.net.wallet_location=C:\mywalletdir
  4. Then you can use a thin JDBC connection string in your application like so: jdbc:oracle:thin:/@MY_WALLET_DB_ENTRY
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜