简单问题,帮帮忙看看

shanshan2004 2004-07-09 07:13:03
我这段代码,老报数据库错误,不知道为什么。我用的mysql


public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
CustomerForm customerForm = (CustomerForm) form;

DataSource dataSource;
Connection cnn;
Statement stmt = null;
ResultSet rs = null;
dataSource = getDataSource(request);
cnn = dataSource.getConnection();
stmt = cnn.createStatement();

try {


rs =
stmt.executeQuery(
"insert into custom values('1','"+customerForm.getCUSTOMNAME()+"','"+customerForm.getCOUNTRY()+"','"
+ customerForm.getADDRESS()
+"','"
+customerForm.getDESCRIPTION()
+ "','"
+ customerForm.getLXR()
+"','"
+customerForm.getTEL()
+"','"
+customerForm.getCP()
+"','"
+customerForm.getFAX()
+"','"
+customerForm.getBP()
+"','"
+customerForm.getZIPCODE()
+ "')");

//插入一条纪录


return (mapping.findForward("success"));



} catch (SQLException e) {

throw new SQLException("insert into database error");

}
finally {
try {
rs.close();
stmt.close();
cnn.close();
} catch (Exception ex) {
System.out.println("Error closing database");
}
}



}





...全文
113 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shanshan2004 2004-07-09
  • 打赏
  • 举报
回复
解题
shanshan2004 2004-07-09
  • 打赏
  • 举报
回复
自己解决了
ninghao37 2004-07-09
  • 打赏
  • 举报
回复
把错误帖出来啊
shanshan2004 2004-07-09
  • 打赏
  • 举报
回复
快来人阿

81,122

社区成员

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

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