gpt4 book ai didi

oracle - Tomcat 无法创建 TCPS Oracle JDBC 连接

转载 作者:行者123 更新时间:2023-11-28 22:52:16 30 4
gpt4 key购买 nike

我在 tomcat 中通过 JDBC 使用数据库连接。我们的环境是Tomcat 7 + JDK 8和Oracle 12c。

因为我只能通过 TCPS 连接到 Oracle 数据库(我们正在使用 Oracle 的钱包),所以我必须修改我当前的 Tomcat server.xml 以创建到 Oracle 的 JDBC 连接。我更新的配置片段

    <Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver"
initialSize="10"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx(threshold=10000)"
jmxEnabled="true" logAbandoned="true" maxActive="100" maxIdle="100"
maxWait="10000"
name="jdbc/jndiconnection" password="XXXXXX" removeAbandoned="true"
type="javax.sql.DataSource" url=""jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=hostname)(PORT=1234))(CONNECT_DATA=(SERVICE_NAME=servicename)))"
username="XXXXXXXX" validationInterval="30000" validationQuery="SELECT 1 FROM DUAL" />

我添加了 truststore/trusttypey/keystore/keytype 作为参数,但是我得到了错误:

Caused by: oracle.net.ns.NetException: Unable to initialize ssl context.
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:296)
at oracle.net.nt.TcpsNTAdapter.connect(TcpsNTAdapter.java:117)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 73 more
Caused by: oracle.net.ns.NetException: Unable to initialize the key store.
at oracle.net.nt.CustomSSLSocketFactory.getKeyManagerArray(CustomSSLSocketFactory.java:369)
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:279)
... 76 more
Caused by: java.security.KeyStoreException: SSO not found
at java.security.KeyStore.getInstance(KeyStore.java:851)
at oracle.net.nt.CustomSSLSocketFactory.getKeyManagerArray(CustomSSLSocketFactory.java:357)
... 77 more
Caused by: java.security.NoSuchAlgorithmException: SSO KeyStore not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
at java.security.Security.getImpl(Security.java:695)
at java.security.KeyStore.getInstance(KeyStore.java:848)
... 78 more

然后我按照来自 https://sysapp.wordpress.com/2010/08/31/how-to-oracle-wallet-with-jdbc-thin-driver-datasource-tomcat/ 的指示进行操作但是在文章中它使用 PROTOCAL 作为 TCP 而不是 TCPS。

<Resource
name="jdbc/confluence"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:/@mywallet"
connectionProperties=”oracle.net.wallet_location=/opt/wallet"/>

然后我得到了错误:

Caused by: oracle.net.ns.NetException: The method specified in wallet_location is not supported. Location: /opt/wallet
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:219)
at oracle.net.nt.TcpsNTAdapter.connect(TcpsNTAdapter.java:117)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 73 more

我已经编写了 Java 示例代码来通过 TCPS 进行连接,并且连接工作正常。我是否遗漏了配置文件中的一些关键点?还有其他方法可以通过 JDBC 创建 Oracle 的 TCPS 连接吗?

最佳答案

”oracle.net.wallet_location=/opt/wallet"

这不是该属性应有的样子。它应该是:

(SOURCE=(METHOD=file)(METHOD_DATA=(DIRECTORY=/opt/wallet)))

您收到的错误消息是因为它无法在您提供的方法中找到“METHOD=”。

关于oracle - Tomcat 无法创建 TCPS Oracle JDBC 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36524581/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com