简单问题,帮帮忙看看

shanshan2004 shanshan2004 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我这段代码,老报数据库错误,不知道为什么。我用的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");
}
}



}





...全文
评论 4
收藏 已收藏
分享
返回顶部
shanshan2004
Web 开发 81,108 成员 341,721 内容