public void Update(String name, String mobile, String email, String car, String model, String year, String color, String plate_no, String plateletters,String gear, String km, String date,String licesnse,String status, String notes){
Connection conn = null;
try{
conn = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
System.out.println("connected");
Statement stmt = (Statement) conn.createStatement();
String ins = "update car"
+ "set Name = '"+name+"' , "
+ "Email = '"+email+"' , "
+ "Car = '"+car+"' , "
+ "Model = '"+model+"' , "
+ "Year = '"+year+"' , "
+ "Color = '"+color+"' , "
+ "Plateno = '"+plate_no+"' , "
+ "Plateletters = '"+plateletters+"' , "
+ "Gearbox = '"+gear+"' , "
+ "Km = '"+km+"' , "
+ "Date = '"+date+"' , "
+ "License = '"+licesnse+"' , "
+ "Status = '"+status+"' , "
+ "Notes = '"+notes+"' "
+ "where Mobile = '"+mobile+"' ";
stmt.execute(ins);
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e.getMessage());
System.err.println(e);
return;
}
}
**我已经试过了 stmt.executeUpdate(ins);
但什么都没用!!
请帮帮我**
错误:
sqlsyntaxerrorexception:您的sql语法有错误;请查看与您的mysql服务器版本对应的手册,以获取在“=”ahmed“,email=”附近使用的正确语法ahmed@hotmail.com'汽车='本田',车型='本田',是'在1号线
2条答案
按热度按时间e4yzc0pl1#
使用
preparedStatement
安装Statement
.liwlm1x92#
您需要确保在sql查询的元素之间添加适当的空间:
应该是
这样做的一个好方法是在数据库查询工具(sqldeveloper、phpmyadmin等)中编写和执行sql,并在尝试用java重新编写之前确保语法良好。