注册 登录
编程论坛 J2EE论坛

数据库抛错

亮剑 发布于 2007-07-20 23:30, 454 次点击

程序代码:

    private static String url = \"jdbc:oracle:thin:@localhost:1521:system\";


    private static String user = \"system\";


    private static String pw = \"19821227\";


    private static Connection con = null;


    public static Connection getConnection() {
        if(con==null){
            try {
                Class.forName(\"oracle.jdbc.driver.OracleDriver\");
                con = DriverManager.getConnection(url, user, pw);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return con;
    }


java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection

这是为什么啊?

2 回复
#2
亮剑2007-07-20 23:31
我的数据库是10G 难道url写的有问题?
#3
a2762024602007-07-20 23:54
你建的数据库名字叫system吗?如果不是就是你url写错了
1