【问题标题】:Mysql Connection problem or my code problem [duplicate]Mysql连接问题或我的代码问题[重复]
【发布时间】:2020-07-28 12:56:43
【问题描述】:

我想用数据库(XAMP SOFTWRE)制作一个小型的员工管理系统软件。 软件我正在使用 NETBEANS

对于我正在使用的数据库连接: 1.JAR = mysql-connector-java-8.0.19 2. BIN = mysql-connector-java-5.1.41.

当我想输入我的信息时,我遇到了问题。谁能帮我解决这个问题?

代码:

    try {
        Class.forName("com.mysql.jdbc.Driver");
        con1 = DriverManager.getConnection("jdbc:mysql://localhost/project1","root","");
        insert = con1.prepareStatement("insert into records(idno,name,occu,dob,pn)values(?,?,?,?,?)");
        insert.setString(1,idno);
        insert.setString(2,name);
        insert.setString(3,occu);
        insert.setString(4,dob);
        insert.setString(5,pn);
        insert.executeUpdate();



        JOptionPane.showMessageDialog(this,"Information has been successfully recorded.");





enter code here

输出结果: 加载类com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'。驱动程序是通过 SPI 自动注册的,通常不需要手动加载驱动程序类。 2020 年 4 月 12 日晚上 11:42:04 project1.reg jButton1ActionPerformed 严重:无 java.sql.SQLException:服务器时区值“未知”无法识别或代表多个时区。如果您想利用时区支持,您必须配置服务器或 JDBC 驱动程序(通过“serverTimezone”配置属性)以使用更具体的时区值。 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) 在 com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)

【问题讨论】:

    标签: java mysql jdbc


    【解决方案1】:

    尝试改变

    com.mysql.jdbc.Driver
    

    com.mysql.cj.jdbc.Driver
    

    【讨论】:

    • 大哥能告诉我CJ是什么意思吗?
    • 看到这个post
    • 加载类com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'。驱动程序是通过 SPI 自动注册的,通常不需要手动加载驱动程序类。 2020 年 4 月 15 日晚上 8:17:08 project1.reg jButton1ActionPerformed 严重:空
    • 同样的问题 :(
    • 这个问题已经问过了,见this
    猜你喜欢
    • 1970-01-01
    • 2011-06-03
    • 1970-01-01
    • 2011-06-15
    • 1970-01-01
    • 2010-09-23
    • 2011-02-16
    • 1970-01-01
    相关资源
    最近更新 更多