本文介绍了如果使用Oracle钱包,正确的JDBC URL语法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

URL语法有2种,旧语法仅适用于SID,新语法具有Oracle服务名称.
旧语法

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]:SID

新语法

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

如果使用Oracle钱包,正确的JDBC URL语法是什么?
根据本文,应使用以下URL语法:

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  

但是正如我所见,以下URL也可以使用:

But as I can see following URL works too:

jdbc:oracle:thin:@db_alias

以下哪种语法是正确的?

Which of these syntaxes are correct?

推荐答案

在将Oracle Wallet与JDBC字符串一起使用时,两种语法都允许,只要在其中设置了"db_alias"显然是您的电子钱包商店.

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.

现在,就将SQL * Plus与Oracle Wallet一起使用而言,Oracle Wallet允许的唯一格式是:

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

/@db_alias

顺便说一句,您所引用的文章(以及其他)指定仅在使用OCI驱动程序而不是瘦客户机的情况下才能使用JDBC进行连接.这通常是因为Java不了解Oracle TNS和SQLNET文件.实际上这是不正确的.您可以使用JDBC瘦驱动程序与最新的Oracle Client& JDBC驱动程序,但只需要进行一些设置即可.请参阅 http ://://tech.shopzilla.com/2011/09/oracle-wallet-with-thin-driver-with-connection-pool-with-database-timeouts/上的信息,下面是简短摘要

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.

将Oracle Wallet与JDBC Thin Driver结合使用

  1. 按常规配置Oracle Wallet (Oracle数据库随附)客户端),在您的tnsnames.ora和sqlnet.ora文件中创建适当的条目,以及在您的钱包中创建凭据条目
  2. 将以下JAR添加到Java类路径中.您应该从Oracle 11g客户端获取这些文件,并且可以在客户端安装位置的"jdbc"和/或"jlib"目录中找到它们.
    • Oracle JDBC驱动程序-ojdbc6.jar
    • Oracle Wallet-oraclepki.jar
    • Oracle安全证书-osdt_cert.jar
    • Oracle Security Core-osdt_core.jar
  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
  • -Doracle.net.tns_admin=C:\myTNSdir
  • -Doracle.net.wallet_location=C:\mywalletdir
  • -Doracle.net.tns_admin=C:\myTNSdir
  • -Doracle.net.wallet_location=C:\mywalletdir

这篇关于如果使用Oracle钱包,正确的JDBC URL语法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 13:59