java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:list
package DisplayAuthors;
import java.sql.*;
public class DisplayAuthors
{
private static final String DATABASE_URL="jdbc:oracle:thin:@localhost:1521:orcl"; //here is 5 rows
public static void main(String[] args) {
Connection connection=null;
Statement statement=null;
ResultSet resultset=null;
try
{
connection=DriverManager.getConnection(DATABASE_URL,"scott","123456");
statement=connection.createStatement();
resultset=statement.executeQuery("select * from emp");
ResultSetMetaData metadata=resultset.getMetaData();
int numberofcolumns=metadata.getColumnCount();
for(int count=1;count<numberofcolumns;count++)
{
System.out.printf("%-8s\t",metadata.getColumnName(count));
}
System.out.println();
while(resultset.next())
{
for(int count=1;count<numberofcolumns;count++)
{
System.out.printf("%-8s\t", resultset.getObject(count));
}
System.out.println();
}
}
catch(SQLException sqlexception)
{
sqlexception.printStackTrace();
}
finally
{
try
{
resultset.close();
statement.close();
connection.close();
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}
}
代码如上,出现这个错误的原因有很多,如果是代码上的原因,就应该检查一下第五行代码那里"dbc:oracle:thin:@localhost:1521:orcl"中的"orcl"是不是创建数据库时的那个SID,如果不是就会出错。注意此处不是连接名,而是SID。
如果这里是正确的,那么就可能是监听程序的错误。这种错误可以自行搜索一下,网上的关于题目上的错误讨论的最多的就是这种原因。可以自行搜索解决方案来解决。
java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:list的更多相关文章
- java.sql.SQLException: Could not establish connection to 192.168.8.111:10000/default: java.net.ConnectException: Connection refused: connect at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveC
java.sql.SQLException: Could not establish connection to 192.168.8.111:10000/default: java.net.Conne ...
- Listener refused the connection with the following error 错误解决
原文地址 :http://blog.csdn.net/zajin/article/details/17753351 做个备份: 查询数据库当前进程的连接数: select count(*) from ...
- 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; 然后再输入密码即可. 然后我的数据库连接工具使用 ...
- Hive中导入Oracle数据错误:Listener refused the connection with the following error: ORA-12505
问题: 今天往Hive中导入Oracle数据的时候碰到了如下错误:Listener refused the connection with the following error: ORA-12505 ...
- Oracle中Error while performing database login with the XXXdriver; Listener refused the connection with the following error; ORA-12505,TNS:listener does not currently know of SID given inconnect descrip
一次连接数据库怎么也连接不上,查了多方面资料,终于找到答案,总结 首先应该保证数据库的服务启动 在myeclipse的数据库视图中点 右键->new 弹出database driver的窗口, ...
- 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 ...
- java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)(ERR=12505)(ERR
dbc 链接orcal出错 java.sql.SQLException: Io 异常: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=186646784)( ...
- java.sql.SQLException: Io 异常: Connection reset
当数据库连接池中的连接被创建而长时间不使用的情况下,该连接会自动回收并失效,但客户端并不知道,在进行数据库操作时仍然使用的是无效的数据库连接,这样,就导致客户端程序报“ java.sql.SQLExc ...
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
org.springframework.dao.TransientDataAccessResourceException: ### Error updating database. Cause: ja ...
随机推荐
- win10双系统安装 linux(manjaro)记录
.clearFloat::after { content: ""; height: 0; display: block; clear: both; visibility: hidd ...
- cubase 的 CC控制器使用
- 【微信小程序】调起微信支付完整demo
微信小程序调用微信支付接口 https://blog.csdn.net/u012667477/article/details/80940578
- Acwing-196-质数距离(素数区间筛法)
链接: https://www.acwing.com/problem/content/198/ 题意: 给定两个整数L和U,你需要在闭区间[L,U]内找到距离最接近的两个相邻质数C1和C2(即C2-C ...
- WIF配置说明
<configuration> <configSections> <!--添加 WIF 4.5 sections :如下两条--> <section name ...
- numpy常用矩阵操作
1.删除列 column_to_delete = [0, 1, 2] arr = np.delete(arr, [0, 1, 2], axis=1) 2.归一化 arr = normalize(arr ...
- CDOJ 1255 斓少摘苹果 图论 2016_5_14
斓少摘苹果 Time Limit: 3000/3000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit St ...
- noi.ac #531 神树和物品
题目链接:戳我 决策单调性 (蒟蒻终于会写决策单调性啦!考试全场切这题就我不会啊嘤) (证明?不会啊,自己打表看QAQ) 44pts \(O(n^2)\)代码: #include<iostrea ...
- 循环数组实现FIFO
涉及到数据通信的软件开发,不能回避的一点是,设计一个实用高效率的数据缓冲区,例如fifo.今天在做项目时候,需要缓存CAN总线上的数据,然后再需要的时候读这些数据.下边给出我自己设计的,采用循环数组实 ...
- git命令行指南
Git 常用命令 git init here -- 创建本地仓库(repository),将会在文件夹下创建一个 .git 文件夹,.git 文件夹里存储了所有的版本信息.标记等内容 git remo ...