mYSQL错误

啦啦啦_Vampire 2013-06-05 12:52:32
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 '12:52:16,pk=1 where id=2' at line 1



源部分代码:用的servlet

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
int idd2=Integer.parseInt(request.getParameter("idd1"));
System.out.println(idd2);

java.util.Date date=new java.util.Date();
java.text.DateFormat myformat = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String nowdate = myformat.format(date);
// Calendar c=Calendar.getInstance();
// java.util.Date d=c.getTime();
// String a=d.toString();//取系统时间
System.out.println(nowdate);
//String currTime=DateFormat.getDateInstance().format(date);
String sql="update chewei set in_time="+nowdate+",pk=1 where id="+idd2+"";
try {

DBConnection lianjie=new DBConnection();
PreparedStatement ps=lianjie.getConn().prepareStatement(sql);
boolean getin=lianjie.executeUpdate(sql);
if(getin==true)
{
System.out.println("成功");
//response.sendRedirect("parking.jsp");

}else
{
System.out.println("出错了3");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("出错了");
}
...全文
309 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
啦啦啦_Vampire 2013-06-16
  • 打赏
  • 举报
回复
版主是对的。。。。。。
Wentasy 2013-06-16
  • 打赏
  • 举报
回复
lxp642 2013-06-06
  • 打赏
  • 举报
回复
最好的办法就是把sql语句打印出来,然后去调式~
啦啦啦_Vampire 2013-06-05
  • 打赏
  • 举报
回复
求大神帮我改改
ACMAIN_CHM 2013-06-05
  • 打赏
  • 举报
回复
String sql="update chewei set in_time='"+nowdate+"',pk=1 where id="+idd2+""; 时间加上单引号。
WWWWA 2013-06-05
  • 打赏
  • 举报
回复
把SQL中的内容显示出来看看 String sql="update chewei set in_time='"+nowdate+"',pk=1 where id="+idd2+"";

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧