1、本机tnsnames.ora 配置如下

test4=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.4)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)

2、代码配置如下:

spring.datasource.url = jdbc:oracle:thin:@192.168.1.4:1521:test4
spring.datasource.username = username
spring.datasource.password = password

spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver

3、看似好像配置没有问题,但是运行起来一直报ORA-12505错误。

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

4、反复测试Oracle服务端监听正常。

5、最后发现配置问题,改正为如下配置:

①spring.datasource.url = jdbc:oracle:thin:@//192.168.1.4:1521/orcl

②spring.datasource.url = jdbc:oracle:thin:@192.168.1.4:1521:orcl

以上两种方法均可以。

6、总结:Oracle有两种配置方式,SID指的是全局数据库名,而并非你本地的tnsnames.ora中配置的别名。

所以,在配置的时候,应该首先知道数据库配置的全局数据库名,再去代码中配置。

格式一:jdbc:oracle:thin:@//<host>:<port>/<service_name>
格式二:jdbc:oracle:thin:@<host>:<port>:<SID> 
格式三:jdbc:oracle:thin:@<TNSName>

关于ORA-12505, TNS:listener does not currently know of SID given in connect descriptor报错问题解决办法的更多相关文章

  1. Connection to Oracle failed. [66000][12505] Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor .

    我安装了Oracle数据库,默认的数据库用户名是system,密码口令是安装过程中你自己设置的.可以先使用命令框,输入 sqlplus system; 然后再输入密码即可. 然后我的数据库连接工具使用 ...

  2. Oracle - ORA-12505, TNS:listener does not currently know of SID given in connect descriptor 解决

    java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:list ...

  3. ORA-12505, TNS:listener does not currently know of SID given in connect descriptor (二)

    异常及解决 在连接sqldeveloper出现的异常信息 在ORA-12505, TNS:listener does not currently know of SID given in connec ...

  4. ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    引子: 本项目在老电脑上用的是oracle10g,换新电脑装的是oracle11g,但运行项目本没有什么关系,本来说创建个用户,用PLSQL手工导入数据,再改几下配置文件即可跑起来--但实际启动中遇到 ...

  5. 连接oracle数据库出现:ORA-12505,TNS:listener does not currently know of SID given in connect descriptor

    Java使用 jdbc:oracle:thin:@11.1.0.14:1521:orcl 连接oracle数据库出现: ORA-12505,TNS:listener does not currentl ...

  6. 66000][12505] Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor oracle.n et.ns.NetException: Listener refuse

    新装的idea开发工具后连接数据库出现如题所示错误. 1.网上搜了不少的文章,没有解决我的问题.后来细心看了一下url: 一开始url是这样子的. jdbc:oracle:thin:@:s21_pdb ...

  7. 【java】ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

    如果是负载均衡,则 jdbc.url=jdbc:oracle:thin:@(description=(address_list= (address=(host=XX.XXX.X.XX) (protoc ...

  8. ORA-12514, TNS:listener does not currently know of service requested in connect descriptor案例2

    今天使用SQL Developer连接一台测试服务器数据库(ORACLE 11g)时,遇到了"ORA-12514, TNS:listener does not currently know ...

  9. oracle ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

    ORA-12514: TNS:listener does not currently know of service requested in connect descriptor 1.看看是不是监听 ...

随机推荐

  1. C# 一些代码小结--UI操作

    C# 一些代码小结--UI操作 使用控件名调用控件 object obj = this.GetType().GetField("控件名", System.Reflection.Bi ...

  2. 浏览器标识ua

    # LinuxLinux / Firefox 29: Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0Linux ...

  3. Linux正则与文本处理工具(10)

    正则表达式 (Regular Expression, RE, 或称为常规表达式)是通过一些特殊字符的排列,用于『查找/替换/删除』一行或多行文字或字符串,简单的说,正则表达式就是用在字串的处理上面的一 ...

  4. collections, time, queue的应用

    collections  (克来克深思) Counter from collections import Counter # 引入模块, 计数器 Counter(康特) s = 'sadfasdfas ...

  5. 网络基础、ftp任务(进度条、计算文件大小、断点续传、搭建框架示例)

    一.网络基础 1.端口,是什么?为什么要有端口? 端口是为了将同一个电脑上的不同程序进行隔离. IP是找电脑:端口是找电脑上的应用程序: 端口范围:1 – 65535 :    1 - 1024 不要 ...

  6. java urlrewrite实现伪静态化

    1.示例 http://www.onlyfun.com/goods/company.jsp?companyId=455326 ==> http://www.onlyfun.com/company ...

  7. ThinkCMF后台验证码不显示,无法登陆怎么办?

    ThinkCMF5在本地部署之后,过一段时间可能会莫名其妙的出现后台验证码不显示的问题,不明就里.着急登陆后台的话,可以先禁用后台验证码,方法如下: 打开文件:/app/admin/controlle ...

  8. js获取n分钟(或n小时或n个月)后(或前)的时间(日期)

    标题有点绕,其实意思就是根据系统当前时间,获取n分钟或n小时或n个月后的时间. 例如:当前时间下,获取10分钟后的时间. var date=new Date(); //1. js获取当前时间 var ...

  9. arm 算力运算

    MIPS: Million Instructions executed Per SecondDMIPS: Dhrystone Million Instructions executed Per Sec ...

  10. Centos配置vsftpd

    #安装vsftpdyum install vsftpd #限制用户只能访问配置的目录,不能访问其他路径#修改vi /etc/vsftpd/vsftpd.conf chroot_list_enable= ...