gpt4 book ai didi

java - 更新表的两列

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:38 25 4
gpt4 key购买 nike

我必须更新我的两列表格

import java.sql.*;
import javax.sql.*;

public class User {

public static void main(String args[]) {
String id = "QZhx_w1eEJ";
String created = "true";
String vmname = "pratap";
String dbUrl = "jdbc:mysql://localhost:3306/test";
String dbClass = "com.mysql.jdbc.Driver";

try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(dbUrl);
Statement stmt = con.createStatement();
stmt.executeUpdate("update userprofil set created='" + created
+ "',vmname='" + vmname + "' where userprofil.id= '" + id
+ "'");
con.close();
} // end try
catch (ClassNotFoundException e) {
e.printStackTrace();
}
catch (SQLException e) {
e.printStackTrace();
}
} // end main
} // end class

这是错误日志

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at User.main(User.java:17)

谁能帮帮我..

谢谢你..

最佳答案

您只需要您的 JDBC MySQL Driver JAR在你的类(class)路径中。

关于java - 更新表的两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10806262/

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