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

后端 未结 1 1932
-上瘾入骨i
-上瘾入骨i 2020-12-28 21:48

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

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


        
相关标签:
1条回答
  • 2020-12-28 22:27

    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 讨论(0)
提交回复
热议问题