Oracle 10g企业版线程“main”中的异常java.sql.SQLException:Io异常:网络适配器无法建立连接?

时间:2015-12-16 05:52:39

标签: java jdbc oracle10g windows-10

大家好我试图连接Oracle 10g企业版(来自Windows 10)

以下是代码:

import java.sql.*;

public class firstjdbc

{

public static void main(String args[])

throws Exception

{

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

String url="jdbc:oracle:thin:@localhost:1158:em";

String uname="student";

String pwd="abc";

Connection con=DriverManager.getConnection(url,uname,pwd);

System.out.println("****connected");

System.out.println("Connection is:"+con);

Statement stmt=con.createStatement();

System.out.println("statement is:"+stmt);

con.close();

}

}

这是抛出的错误:

Exception in thread "main" java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at firstjdbc.main(firstjdbc.java:12)

如果有人遇到类似问题,请寻求帮助。

0 个答案:

没有答案