Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.sql.SQLException:在Netbeans中找不到合适的驱动程序_Java_Mysql_Jdbc - Fatal编程技术网

java.sql.SQLException:在Netbeans中找不到合适的驱动程序

java.sql.SQLException:在Netbeans中找不到合适的驱动程序,java,mysql,jdbc,Java,Mysql,Jdbc,我在一个类中有这段代码,用于连接数据库 package fullhouse; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; public class FullhouseDB { private static Connection databaseConnectie; public static Connection getConnection() {

我在一个类中有这段代码,用于连接数据库

package fullhouse;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class FullhouseDB {

    private static Connection databaseConnectie;


    public static Connection getConnection() {
        if(databaseConnectie == null){
                String connectString = "jdbc:mysql://localhost:3306/fullhouse";
                try {
                     databaseConnectie = DriverManager.getConnection(connectString, "root", "2002112735");
                } catch (SQLException ex) {
                    Logger.getLogger(FullhouseDB.class.getName()).log(Level.SEVERE, null, ex);
            }
            } 

        return databaseConnectie;

    }
我得到了这个错误:

dec 29, 2014 5:05:49 PM fullhouse.FullhouseDB getConnection
SEVERE: null
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/fullhouse

我已经检查了用户名和密码、数据库服务的连接,并且都是正确的。

您需要使用以下命令加载驱动程序类:

Class.forName("com.mysql.jdbc.Driver");
然后定义连接字符串url

String connectString = "jdbc:mysql://localhost:3306/fullhouse";

首先,从url下面的url获取mysql驱动程序文件


然后将此驱动程序文件添加到项目库文件夹中。

类路径中是否有MySQL数据库的驱动程序JAR?标签上是sql server,url上是MySQL?