oracle 10g中的连接被拒绝错误

时间:2013-08-12 18:52:48

标签: oracle oracle10g oracle-sqldeveloper

我是Oracle 10g的初学者。我试图连接Oracle 10g数据库。这是我的代码:

package com.lara;

import java.sql.*;
class X1{
public static void main(String args[])throws Exception{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger1");
Statement stmt=con.createStatement();
String sql="Create table  emp(Sno int,name Varchar(90),age int)";
stmt.execute(sql);
}
}

但是我收到了这个错误:

Exception in thread "main" java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169870080)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.lara.X1.main(X1.java:7)

1 个答案:

答案 0 :(得分:0)

可能是防火墙问题。关闭防火墙或打开端口1521.