ITPub博客

首页 > 应用开发 > > 为什么用java application可以运行?

为什么用java application可以运行?

作者:yesye 时间:2019-09-06 16:59:41 0 删除 编辑

为什么用java application可以运行,但是发布到服务器上用run on server就不能new对象出来?

publicclassTest { 

    privatestaticString url = "jdbc:mysql://127.0.0.1:3306/students";   

    privatestaticString user = "root";  

    privatestaticString password = null;

    privatestaticjava.sql.Connection con = null;    

    static{      

        try{         

            Class.forName("com.mysql.jdbc.Driver");//在这一行报错,Not Found Class Exception       

        } catch(ClassNotFoundException e) {           

            e.printStackTrace();       

        }      

        try{         

            con = DriverManager.getConnection(url, user, password);    

        } catch(SQLException e) {         

            e.printStackTrace();       

    }  

}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2041/viewspace-3133714/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-09-06

  • 博文量
    139
  • 访问量
    9689