prepareStatement问题

大川韬滔 2013-08-08 08:22:45
有代码如下:
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url = "jdbc:mysql://localhost/mydb";
con = DriverManager.getConnection(url,"root","123456");
psm = conn.prepareStatement("INSERT INTO users VALUES(?,?,?,?,?,?)");
psm.setString(1,ID);
psm.setString(2,password);
psm.setString(3,name);
psm.setString(4,sex);
psm.setLong(5,getDate(date));
psm.setString(6,descriptioin);
psm.executeUpdate();
session.setAttribute("user",ID);
response.sendRedirect("index.jsp");
在tomcat8.0中运行报错:
org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 38 in the jsp file: /do_register.jsp


38行代码为:psm = conn.prepareStatement("INSERT INTO users VALUES(?,?,?,?,?,?)");

哪里错了?忘高手指点下!谢谢!
...全文
160 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
大川韬滔 2013-08-09
  • 打赏
  • 举报
回复
引用 7 楼 PropertyName 的回复:
con = DriverManager.getConnection(url,"root","123456"); psm = conn.prepareStatement("INSERT INTO users VALUES(?,?,?,?,?,?)"); 这个连接对象上面是con下面是conn
兄弟真细心! 感谢!
PropertyName 2013-08-09
  • 打赏
  • 举报
回复
con = DriverManager.getConnection(url,"root","123456"); psm = conn.prepareStatement("INSERT INTO users VALUES(?,?,?,?,?,?)"); 这个连接对象上面是con下面是conn
C-J 2013-08-09
  • 打赏
  • 举报
回复
哦,你的数据库是什么的?
C-J 2013-08-09
  • 打赏
  • 举报
回复
说明你的语句有问题咯,一步步看来,你只是把一些代码列出来,没有看到其他...注意几点:看下驱动是否ok?以及连接数据库是否成功?包包类?loading...
大川韬滔 2013-08-08
  • 打赏
  • 举报
回复
引用 4 楼 PropertyName 的回复:
mysql的url不用写端口?
改为String url = "jdbc:mysql://localhost:3306/mydb"; 还是一样的错误!
白开水MD5 2013-08-08
  • 打赏
  • 举报
回复
引用 4 楼 PropertyName 的回复:
mysql的url不用写端口?
PropertyName 2013-08-08
  • 打赏
  • 举报
回复
mysql的url不用写端口?
白开水MD5 2013-08-08
  • 打赏
  • 举报
回复
http://blog.csdn.net/yinyuan1987/article/details/3176908 不行就重新建一个项目 也可能是项目的问题
大川韬滔 2013-08-08
  • 打赏
  • 举报
回复
引用 1 楼 xiaoxin2007 的回复:
An error occurred at line: 38 in the jsp file: /do_register.jsp 这个错误显示你有个jsp文件叫do_register.jsp,这个文件写得有问题,而不是prepareStatement的问题
大哥,上面的代码就是do_register.jsp页面内的!
Ailsa_Ailsa_Ailsa 2013-08-08
  • 打赏
  • 举报
回复
An error occurred at line: 38 in the jsp file: /do_register.jsp 这个错误显示你有个jsp文件叫do_register.jsp,这个文件写得有问题,而不是prepareStatement的问题

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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