小编典典

找不到JDBC驱动程序

java

try
        {
            String userName = "root";
            String password = "";
            //<facility> is my database
            String url = "jdbc:mysql://localhost/facility";
            Class.forName ("com.mysql.jdbc.Driver").newInstance ();
            conn = DriverManager.getConnection (url, userName, password);
            System.out.println ("Database connection established");
        }
        catch (Exception e)
        {
            System.out.println ("Cannot connect to database server " +e.getClass().getName());

        }

输出 >无法连接到数据库服务器java.lang.ClassNotFoundException


阅读 506

收藏
2020-11-30

共1个答案

小编典典

看来您应该将MySQL驱动程序jar放入 类路径中

2020-11-30