gpt4 book ai didi

java - MySQL - SQLException : No suitable driver found for jdbc:derby://

转载 作者:太空宇宙 更新时间:2023-11-03 11:52:58 24 4
gpt4 key购买 nike

我是一个编程菜鸟,所以请对我温柔点;_;

基本上 - 我已经创建了一个 MySQL Java 数据库,但我收到了这个错误:

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/StudentScores

只有当我运行它时才在编译过程中不显示错误,填写详细信息并单击“添加学生”(数据库存储考试分数的学生详细信息)

这是代码

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

try
{
String url = "jdbc:derby://localhost:1527/StudentScores ";
String username = "admin3";
String password = "admin3";

Connection con = DriverManager.getConnection(url, username, password);
Statement stmt = con.createStatement();
String Query = "INSERT INTO STUDENT (NAME, DATEOFQUIZ, MEMORYSCORE, COMPREHENSIONSCORE, PROBLEMSOLVINGSCORE, AVERAGEPERCENTAGE) VALUES ('"+NameText.getText()+"','"+DateText.getValue()+"','"+MemoryScoreText.getText()+"','"+ComprehensionScoreText.getText()+"','"+ProblemSolvingScoreText.getText()+"', '"+AveragePercentageText.getText()+"')";

JOptionPane.showMessageDialog(null, "Student Added");

NameText.setText(null);
DateText.setText("00/00/0000");
MemoryScoreText.setText(null);
ComprehensionScoreText.setText(null);
ProblemSolvingScoreText.setText(null);
AveragePercentageText.setText(null);

}
catch(SQLException ex)
{
JOptionPane.showMessageDialog(null, ex.toString());
}
}

帮帮我?谢谢:)

最佳答案

您正在尝试加载 Derby 驱动程序,而不是用于 MySQL 的驱动程序。您的 JDBC 网址应该是

jdbc:mysql://localhost:3306/StudentScores

相反。如果修复后仍然出现相同的异常,那么您需要确保 MySQL 驱动程序 jar 文件在您的类路径中。

关于java - MySQL - SQLException : No suitable driver found for jdbc:derby://,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34582278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com