| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1261 人关注过本帖
标题:[求助]连接出错,不明白请教.
只看楼主 加入收藏
wxhwjsw
Rank: 1
等 级:新手上路
帖 子:274
专家分:0
注 册:2006-6-15
收藏
 问题点数:0 回复次数:0 
[求助]连接出错,不明白请教.

程序如下:
package mypackage;
import java.sql.*;
import java.sql.SQLException.*;
import oracle.jdbc.driver.*;

public class AccessingClass
{
Connection conn;
public void initialize() throws SQLException
{
/*//加载方法(1)
Class.forName("oracle.jdbc.driver.OracleDirver");
//加载方法(2)
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDirver());*/
//加载方法(3)
OracleDriver driver = new OracleDriver();
conn = DriverManager.getConnection
("jdbc:oracle:thin:@simon:1521:oracledb1","sysman","orcl");
conn.setAutoCommit(false);
System.out.println("连接成功!"); //在initialize()方法中:
}

public AccessingClass()
{
}
public static void main(String args[] ) throws SQLException
{
AccessingClass accessingClass = new AccessingClass( );
System.out.println("The arguments are : " + args[0]
+ ", " + args[1] + ", " + args[2]);
accessingClass.initialize();
}
}

出错提示:
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:
simon:1521:oracledb1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:279)

at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:327)

at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:365)

at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:150)

at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:31)

at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:563)

at java.sql.DriverManager.getConnection(DriverManager.java:512)

at java.sql.DriverManager.getConnection(DriverManager.java:171)

at mypackage.AccessingClass.initialize(AccessingClass.java:16)

at mypackage.AccessingClass.main(AccessingClass.java:31)

Process exited with exit code 1.

搜索更多相关主题的帖子: class void package public import 
2006-08-04 12:26
快速回复:[求助]连接出错,不明白请教.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032908 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved