我的程序结构是:jsp+tomcat+oracle(linux)
oracle在linux服务器上,我的程序以前一直是好的,连接没有问题,自从服务器重启一次后,就出现了java.sql.SQLException: Io exception: The Network Adapter could not establish the connection这样的问题,我可以用sqlplus连接到数据库上,但是程序却不能,请大虾指教,指出问题可能出在哪些方面!
oracle在linux服务器上,我的程序以前一直是好的,连接没有问题,自从服务器重启一次后,就出现了java.sql.SQLException: Io exception: The Network Adapter could not establish the connection这样的问题,我可以用sqlplus连接到数据库上,但是程序却不能,请大虾指教,指出问题可能出在哪些方面!
我的程序一直没有改,不知道是不是oracle的设置改变了什么的,就是不清楚问题在哪里
public class zj_linkdb
{
public Connection connection;
private String url=new String("jdbc:oracle:thin:@host:1521:sid");
private String username =new String("name");
private String password =new String("password");
private String driver =new String("oracle.jdbc.driver.OracleDriver");
public static void main(String[] args)
{
try {
Class.forName(driver);
connection = DriverManager.getConnection(url, username, password);
}
catch ( ClassNotFoundException cnfex ) {
System.err.println(
"装载 JDBC/ODBC 驱动程序失败。" );
cnfex.printStackTrace();
System.exit( 1 );
}
catch ( SQLException sqlex ) {
System.err.println( "don't link to db!" );
sqlex.printStackTrace();
System.exit( 1 );
}
}
}
我把程序大概列出来了,host和sid都就不写出来了
一连接就报错
don't link to db!
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
2. 把程序改成这样看看
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String s = "jdbc:oracle:thin........";
Connection conn = DriverManager.getConnection(s,username, password);
在客户端上执行:telnet serverhost the-port-number