简体   繁体   English

线程“ main”中的异常java.sql.SQLException:找不到适合的驱动程序

[英]Exception in thread “main” java.sql.SQLException: No suitable driver found for

I'm trying to connect to a MySQL database, I created the SQL database with phpmyadmin on localhost. 我试图连接到MySQL数据库,我在localhost上用phpmyadmin创建了SQL数据库。 My code seems correct and I have the JAR file added to eclipse. 我的代码似乎正确,并且我已将JAR文件添加到eclipse中。 I have googled the error and found on here many topics that are the same but haven't been able to resolve the problem. 我已经搜索了该错误,并在此处找到了许多相同但无法解决问题的主题。 Here is my code: 这是我的代码:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;


public class dbconnection {
    public static void main (String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:msql://localhost:3306/g52apr","root", "");
        java.sql.PreparedStatement statement = con.prepareStatement("select * from std_details");
        ResultSet result = statement.executeQuery();
        while (result.next()){
            System.out.println(result.getString(1) + " " + result.getString(2));
        }
    }
}

This is the exact error: 这是确切的错误:

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:microsoft:sqlserver://localhost:3306/g52apr
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at dbconnection.main(dbconnection.java:10)
"jdbc:msql://localhost:3306/g52apr"

should be: 应该:

"jdbc:mysql://localhost:3306/g52apr"

Edited Changed SQL Server reference to MySql 编辑对MySql的更改的SQL Server参考

暂无
暂无

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

相关问题 线程“主”java.sql.SQLException 中的异常:未找到适合 jdbc:ucanaccess://C:/Users/gfas1/acctop/. - Exception in thread “main” java.sql.SQLException: No suitable driver found for jdbc:ucanaccess://C:/Users/gfas1/Desktop/st.accdb 如何解决异常java.sql.SQLException:没有找到合适的驱动程序? - How to solve an exception java.sql.SQLException: No suitable driver found? 例外:java.sql.SQLException:没有为jdbc找到合适的驱动程序:ucanaccess - Exception: java.sql.SQLException: No suitable driver found for jdbc:ucanaccess java.sql.SQLException:找不到适合的驱动程序 - java.sql.SQLException: No suitable driver found for java.sql.SQLException:找不到合适的驱动程序 - java.sql.SQLException: No suitable driver found java.sql.SQLException:找不到适合的驱动程序 - java.sql.SQLException: No suitable driver found for 线程“主”中的异常java.sql.SQLException:找不到数据 - Exception in thread “main” java.sql.SQLException: No data found Exception in thread "AWT-EventQueue-0" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/gestaocondominio - Exception in thread "AWT-EventQueue-0" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/gestaocondominio 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
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM