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#]Dapper学习笔记

    1.安装,直接用nuget搜索Dapper就行,不过只支持框架4.5.1 2.数据库测试表 CREATE TABLE [dbo].[Student]( [ID] [bigint] NULL, ) NU ...

  2. 题解 P5091 【【模板】欧拉定理】

    欧拉定理:若 \(gcd(a,n)=1\),\(a^{\varphi(n)}\equiv 1(mod\ n)\) 设 \(1\sim n-1\) 中与 \(n\) 互素的 \(\varphi(n)\) ...

  3. Apache VirtualHost的配置

    自从电脑更换为mac后, 一直没有时间去配置php的环境.导致每次要更改php代码的时候, 都是本地更改,然后直接推送到服务器上运行 这样的开发和测试及其耗时且繁琐, 所以早上特地决定弄好mac下的p ...

  4. 调用notify()后,当前线程执行完synchronized块中的所有代码才会释放锁

    package com.pinnet.test; public class Demo { public static void main(String[] args) { Demo demo = ne ...

  5. GITLAB安装笔记

    CentOS 7 最小安装后操作 设置时区timedatectl set-timezone Asia/Shanghai 添加 Gitlab 清华源 vi /etc/yum.repos.d/gitlab ...

  6. POJ 2782

    #include <iostream> #include <algorithm> #define MAXN 100005 using namespace std; int _m ...

  7. gulp的安装以及使用详解,除了详细还是详细

    安装gulp: 1. 创建本地包管理环境: 使用npm init命令在本地生成一个package.json文件,package.json是用来记录你当前这个项目依赖了哪些包,以后别人拿到你这个项目后, ...

  8. 05-01 Java 方法

    方法 方法定义.格式: /* 方法:完成特定功能的代码块. 注意:在很多语言里面有函数的定义,而在Java中函数被称为方法. 方法格式: 修饰符 返回值类型 方法名(参数类型 参数名1,参数类型 参数 ...

  9. Spring Boot启动流程

    基础准备 1,BeanPostProcessor:这个接口的作用在于对于新构造的实例可以做一些自定义的修改.比如如何构造.属性值的修改.构造器的选择等等 2,BeanFactoryPostProces ...

  10. Zookeeper--0200--安装与集群搭建、常用命令、客户端工具

    看这里,http://www.cnblogs.com/lihaoyang/p/8358153.html 1,先使用可视化客户端软件 ZooInspector 连接上集群中的一个节点,看下zk的结构: ...