`

Io 异常: The Network Adapter could not establish the

阅读更多
package org.jinjiabao.jdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class TestConnection {
	public static void main(String[] args) throws ClassNotFoundException, SQLException{
		String user = "lisi";
		String password = "lisi";
//String url = "jdbc:oracle:thin:@localhost:1521:ORCL";
		String url = "jdbc:oracle:thin:@192.168.1.100:1521:ORCL";
		String driver = "oracle.jdbc.driver.OracleDriver";
		Class.forName(driver);
		
		Connection conn = DriverManager.getConnection(url, user, password);
		
		System.out.println("Connection: " + conn);
	}
}

 出现的异常:

Exception in thread "main" java.sql.SQLRecoverableException: Io 异常: The Network Adapter could not establish the connection
	at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:458)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
	at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
	at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:465)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:185)
	at org.jinjiabao.jdbc.TestConnection.main(TestConnection.java:21)
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics