简单问题,帮帮忙看看
我这段代码,老报数据库错误,不知道为什么。我用的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");
}
}
}