当前位置: 代码迷 >> Java Web开发 >> JSP 更新 MySQL 语句时遇到异常了= =
  详细解决方案

JSP 更新 MySQL 语句时遇到异常了= =

热度:5595   发布时间:2013-02-25 21:21:55.0
JSP 更新 MySQL 语句时遇到错误了= =
String sql="update thing set tname="+name+",tprice="+price+",tdetail="+pho+",tnum="+no+" where tID='"+id+"'";
System.out.println(sql);
try {
st.executeUpdate(sql);
st.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



报错:
update thing set tname=,tprice=,tdetail=,tnum= where tID='null'
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tprice=,tdetail=,tnum= where tID='null'' at line 1
路过的大神帮帮忙吧T T

------解决方案--------------------------------------------------------
tID='"+id+"'多了个''吧,或者前面的tname="+name+",tprice="+price+",tdetail="+pho+",tnum="+no+"少了'',你可以试一下
  相关解决方案