最近使用java连接oracle数据库的时候总会出现怪事情。几周前我用下面的代码能够连接上,并且能够在数据库中进行操作,代码如下:
public class TTest {
public static final String DBDRIVER = "oracle.jdbc.driver.OracleDriver";
public static final String DBURL = "jdbc:oracle:thin:@localhost:1521:Miujg";
public static final String DBUSER = "scott";
public static final String PASSWORD = "tiger";
private Connection conn = null;
public static void main(String[] args)throws Exception {
Connection ct=null;
Class.forName(DBDRIVER);
ct=DriverManager.getConnection(DBURL,DBUSER,PASSWORD);
System.out.println(ct);
}
}
现在连接总是出现: Io 异常: The Network Adapter could not establish the connection。网上说是没有打开那两个服务(一个是监听,另一个是OracleService),但是我都打开了的,昨晚我重新启动这两个服务又可以连接,但是今天我有照着昨天的做,还是不能够连接。我tm快疯了,求大神相助呀。