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. .net中的SelectList在Html.DropdownList中的使用

    .net中的SelectList可以用于前端下拉框的内容填充 譬如:Html.DropdownList(下拉框标签名称, SelectList实例) 实际上,上述Html.DropdownList的第 ...

  2. 【计算机网络】数据交换技术和多路复用技术的正(nao)确(can)打开方式

    交换的作用   数据交换是计算机网络中两个终端进行数据传输的方式,它又可以分成两种类型:电路交换和分组交换.很显然,问题的核心在于“交换”,那么我们首先要思考的是:交换的作用是什么?   “交换”的作 ...

  3. BZOJ 5194--[Usaco2018 Feb]Snow Boots(STL)

    5194: [Usaco2018 Feb]Snow Boots Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 81  Solved: 61[Submi ...

  4. python 多版本管理pyenv和virtualenv虚拟开发环境

    pyenv是管理多个python版本的工具. 1.pyenv的安装 git clone https://github.com/yyuu/pyenv.git ~/.pyenv 2.将PYENV_ROOT ...

  5. 关于Python2和Python3之间的文本模型改变

    原文地址:http://python-notes.curiousefficiency.org/en/latest/python3/questions_and_answers.html#what-act ...

  6. C语言写了一个socket client端,适合windows和linux,用GCC编译运行通过

    ////////////////////////////////////////////////////////////////////////////////* gcc -Wall -o c1 c1 ...

  7. asp.net core中遇到需要自定义数据包解密方法的时候

    最近将公司的项目用.netcore重写, 服务的http外部接口部分收发消息是DES加解密的, 那么在asp.net core mvc的action处理之前需要加入解密这个步骤. 我第一想到的是用fi ...

  8. Java实现二叉树先序,中序,后序,层次遍历

    一.以下是我要解析的一个二叉树的模型形状.本文实现了以下方式的遍历: 1.用递归的方法实现了前序.中序.后序的遍历: 2.利用队列的方法实现层次遍历: 3.用堆栈的方法实现前序.中序.后序的遍历. . ...

  9. MVC3学习:利用jquery+ajax生成二维码(支持中文)

    二维码越来越热火了,做电子商务网站,不做二维码,你就OUT了. 一.下载DLL文件(ThoughtWorks.QRCode.dll),并在项目中引用.点此下载 如果你还不知道什么是QRCode二维码, ...

  10. Java代码操作HDFS测试类

    1.Java代码操作HDFS需要用到Jar包和Java类 Jar包: hadoop-common-2.6.0.jar和hadoop-hdfs-2.6.0.jar Java类: java.net.URL ...