简体   繁体   English

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

[英]java.sql.SQLException: No suitable driver found in Netbeans

I have this code in a class for the connection to the database. 我在用于连接数据库的类中具有此代码。

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;

    }

And I get this error: 我得到这个错误:

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

I've checked the username and password, the connection of database services, and all is correct. 我已经检查了用户名和密码,数据库服务的连接,并且一切正确。

You need to load the driver class using: 您需要使用以下命令加载驱动程序类:

Class.forName("com.mysql.jdbc.Driver");

And then define connect string url. 然后定义连接字符串的URL。

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

First you take mysql driver file from the url below url 首先,您从url下面的url中获取mysql驱动程序文件

http://projectshub.in/softwares/mysql/mysql-connector-java-5.0.8-bin.jar http://projectshub.in/softwares/mysql/mysql-connector-java-5.0.8-bin.jar

than add this driver file to your project lib folder. 将此驱动程序文件添加到您的项目lib文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.sql.SQLException:未找到适合于netbeans的驱动程序 - java.sql.SQLException: No suitable driver found for netbeans java.sql.SQLException:找不到适合的驱动程序 - java.sql.SQLException: No suitable driver found for java.sql.SQLException:找不到适合的驱动程序 - java.sql.SQLException: No suitable driver found for java.sql.SQLException:找不到合适的驱动程序 - java.sql.SQLException: No suitable driver found 首次连接到Netbeans SQL数据库 - java.sql.SQLException:找不到合适的驱动程序0 08001 - Connecting to Netbeans SQL Database for the first time - java.sql.SQLException: No suitable driver found 0 08001 SEVERE: null in java netbeans 14 java.sql.SQLException: No suitable driver found for error - SEVERE: null in java netbeans 14 java.sql.SQLException: No suitable driver found for error java.sql.SQLException找不到合适的驱动程序,但可以在Netbeans中完美连接 - java.sql.SQLException no suitable driver found but can connect perfectly in Netbeans Java + Jersey + Gradle-java.sql.SQLException:找不到合适的驱动程序 - Java + Jersey + Gradle - java.sql.SQLException: No suitable driver found java.sql.SQLException:找不到适合jdbc:oracle:thin的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:oracle:thin java.sql.SQLException:找不到适用于jdbc:derby的驱动程序: - java.sql.SQLException: No suitable driver found for jdbc:derby:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM