简单问题,帮帮忙看看
我这段代码,老报数据库错误,不知道为什么。我用的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");
}
}
}
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");
}
}
}
...全文
相关推荐
XXX现代农业科技示范园项目可行性研究报告.docx
XXX现代农业科技示范园项目可行性研究报告.docx
Fragment与ViewPager构建动态Android主界面
创建自定义的PagerAdapter首先需要继承自类,并重写必要的方法以实现分页功能。以下是创建自定义PagerAdapter的基本步骤:继承PagerAdapter类:创建一个类并继承自。重写抽象方法:重写等抽象方法。实现高级功能:根据需要重写和等方法来控制页面的布局。自定义数据源:根据自己的需求设计和实现数据源,如从网络加载数据。实现页面创建逻辑:编写方法,根据位置创建页面。管理页面销毁逻辑:编写。
某现代农业科技示范园项目规划方案.docx
某现代农业科技示范园项目规划方案.docx
现代农业示范园建设规划.docx
现代农业示范园建设规划.docx
XXX项目可行性研究报告(标准通用大纲框架).docx
XXX项目可行性研究报告(标准通用大纲框架).docx


Web 开发
