确认oracle的两个service服务是否打开了???
OracleOraDb10g_home1TNSListener
OracleServiceORCL
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
The Connection descriptor used by the client was:
localhost:1521:ORCL
一次连接数据库怎么也连接不上,查了多方面资料,终于找到答案,总结
首先应该保证数据库的服务启动
在myeclipse的数据库视图中点 右键->new 弹出database driver的窗口,
Driver template选择oracle(thin driver),
Driver name 输入oracle
connection URL=jdbc:oracle:thin:@localhost:1521:oracle 注意localhost:1521:oracle中的oracle是数据库得sid 换成你自己数据库的sid 就可以
username:登陆数据库具有system权限的用户名
password:登陆数据库具有system权限的密码
点击add jar 选择ojdbc14.jar的存放位置,没有得可以到百度下一个叫ojdbc14.jar的文件。
点击test driver 到此成功配置。
关于启动数据库后提示ora-12505的解决方法:
"listener does not currently know of SID given in connect descriptor "
第一种可能
是配置得数据库sid 名不正确localhost:1521:oracle 即红字部分不是你本机得sid ,那么如何查看本机得sid 呢?
用如下命令 SELECT NAME FROM v$database ;应该是以sysdba的身份进行的操作,在sqlplus中执行就可以看到,把红字部分换成查询出来的sid 就可以。

第二种可能
发现sid 配置没有错误,但是还是报错,那可能就是oracle得监听配置出了问题,需要检查listener .ora文件,用记事本打开,
正确配置如下:
# listener .ora Network Configuration File: e:\oracle\product\10.2.0\db_1\network\admin\listener .ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = e:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = oracle )
(ORACLE_HOME = e:\oracle\product\10.2.0\db_1)
(SID_NAME = oracle )
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
红字部分改成oracle 创建时候的sid 保存退出。
分享到:
相关推荐
The Network Adapter could not establish the connection
当遇到“连接不到数据库”的问题时,通常会显示如"Io异常: The Network Adapter could not establish the connection"这样的错误信息。这个异常表明应用程序无法与数据库建立网络连接,可能由多种原因造成。以下是...
6. 连接 Oracle 时抛出如下异常:java.sql.SQLException: Io exception: The Network Adapter could not establish connection 解决方法: * 检查 Oracle 实例是否正常运行。 * 检查连接数据库的用户名和密码是否...
当你尝试`Test Driver`时,可能会遇到“Error while performing database login with the oracle.jdbc.driver.OracleDriver driver: Io exception: The Network Adapter could not establish the connection”的错误...