关于java和Oracle数据库连接的问题。

sky_pacer_2008 2008-07-08 08:49:56
import java.sql.*;
public class testJDBC {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection a=DriverManager.getConnection
("jdbc:oracle:thin:@192.168.1.2:1521:bjspdgis","xukai","123456");

}
}
这是我测试连接Oracle数据库的代码,但不知道为什么总是报错如下:
Exception in thread "main" 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:
192.168.1.2:1521:bjspdgis
我不明白,bjspdgis因该是数据库对外提供服务的名字吧,但是如何查看我自己数据库的这个名字啊?见笑了,本人菜鸟一个,哪位大虾耐心讲解一下。
...全文
53 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sky_pacer_2008 2008-07-08
  • 打赏
  • 举报
回复
恩,谢谢。
老紫竹 2008-07-08
  • 打赏
  • 举报
回复
还有,不行的话,建议你到Oracle那面问问吧,这个虽然异常在Java,但解决还是Oracle的专家更熟悉
老紫竹 2008-07-08
  • 打赏
  • 举报
回复
哦!你已经发现这个问题啦!有个 tnsname 的配置文件,你打开看看。

老紫竹 2008-07-08
  • 打赏
  • 举报
回复
bjspdgis

这个是SID, 你的数据库真的有这个SID吗? 默认是orcl ,这个可不是随便写的。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧