You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot使用TNS Wallet连接Oracle自治数据库失败求助

SpringBoot连接Oracle自治数据库遇ORA-12506错误解决

即使关闭数据库ACL,仍遇到以下连接错误:

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12506, TNS:listener rejected connection based on service ACL filtering

我的application.properties初始配置如下:

spring.application.name=hr_data
database=oracle
spring.datasource.url=jdbc:oracle:thin:@(description= (retry_count=1)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=123_mydb_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))?TNS_ADMIN=F:/Downloads/Wallet_myDB
spring.datasource.username=ADMIN123
spring.datasource.password=123
spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#logging.level.org.springframework=DEBUG
oracle.net.tns_admin=F:/Downloads/Wallet_myDB

已通过SQL Developer使用下载的Wallet成功连接数据库。

已尝试的操作:

  • 在Oracle中开启访问控制列表并添加本地IP,无效
  • 尝试在连接字符串和oracle.net.tns_admin中配置TNS_ADMIN的多种组合,无效
  • 尝试通过手动@Configuration类实现连接,无效
  • 尝试使用路径F:\Downloads\Wallet_myDB和F:/Downloads/Wallet_myDB,无效

问题已解决
正确的application.properties配置如下:

spring.datasource.url=jdbc:oracle:thin:@(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.ap-mumbai-1.oraclecloud.com))(connect_data=(service_name=abv_mydb_high.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))
TNS_ADMIN=F:/Downloads/Wallet_myDB
spring.datasource.username=ADMIN123
spring.datasource.password=123

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 05:22:09