MySQL8.0.15版本
MySQL-connector-java-8.0.15接口
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import java.sql.*;
public class Main extends Application {
public static void main(String[] args) throws Exception {
Statement statement = null;
Connection connection = null;
ResultSet resultSet = null;
try {
connection =
DriverManager.getConnection("jdbc:mysql://localhost/firma?" +
"user=root&password=database123");
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
launch(args);
}
SQLException:找不到适合jdbc的驱动程序:mysql://localhost/firma?用户=根密码=数据库123
州:08001
供应商错误:0
SQLException:服务器时区值“rodkowoeuropejski czas stand”无法识别或表示多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
SQL状态:01S00
供应商错误:0
DriverManager.getConnection("jdbc:mysql://localhost/firma?useLegacyDatetimeCode=false&serverTimezone=UTC?" +
"user=root&password=database123");
最后我得到:
SQLException:拒绝用户“@”localhost的访问(使用密码:是)
州:28000
为什么他不在这里显示用户名?
数据库存在,url中的用户和密码正确。
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
从控制台我可以登录到mysql没有任何问题。
求你了,帮帮我。我的手已经掉下来了。。。