xhu_cf
2011-07-27 17:31
浏览 246
已采纳

java使用JDBC连接oracle数据库总是出错java io 异常 : the newtwork adapter could not establish

java使用JDBC连接oracle数据库总是出错java io 异常 : the newtwork adapter  could not establish the connection


package staticUtil.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Database {

static {
try {
// 1、加载oracle驱动程序
Class.forName("oracle.jdbc.OracleDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();

}

}

private static String url = "jdbc:oracle:thin:@99.1.1.32:1521:ORCL";
private static String user = "nmc";
private static String password = "123456";

public static Connection getConnection(){
Connection connection = null;
try {
// 2、获取连接
connection = DriverManager.getConnection(url, user, password);
// System.out.println("连接成功");
} catch (SQLException e) {
e.printStackTrace();
// System.out.println("连接数据库失败!!");
}
return connection;
}

}

各方面检查都没有错,到底什么原因呢?

9条回答 默认 最新

相关推荐 更多相似问题