Jsp中向Mysql数据库表插入记录的问题

当向Mysql数据库表中查询时,正常。可是向Mysql数据库表插入新纪录时,数据库表并没有没有插入成功,程序没有提示错误
代码如下:
package com.login.struts;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class SetproblemAction extends Action {
Dbdriver db=new Dbdriver();
/* (non-Javadoc)
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
Connection connection=null;
Statement statement=null;
public SetproblemAction()
{
String userName="root";//数据库用户名
String userPasswd="";//密码
String dbName="acmdata";//数据库名
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;//联结字符串
try {
Class.forName("com.mysql.jdbc.Driver").newInstance(); //加载Mysql数据库驱动
}
catch (Exception e1) {
e1.printStackTrace();
}
try{
connection = DriverManager.getConnection(url); //建立连接这里student为数据库名
statement = connection.createStatement();
}catch(SQLException e1){
e1.getStackTrace();
}
}
public void add(String s1,String s2,String s3,String s4,String s5)
{
String sql="";
try{
sql="INSERT INTO problem(No,title,describe,input,output)VALUES('"+s1+"','"+s2+"', '"+s3+"','"+s4+"','"+s5+"')";
ResultSet rs= statement.executeQuery(sql);
while(rs.next())
{
String number = rs.getString("No");
String title = rs.getString("title");
String describe = rs.getString("describe");
String input = rs.getString("input");
String output = rs.getString("output");
System.out.print(number);
System.out.print(title);
System.out.print(describe);
System.out.print(input);
System.out.print(output);
}
}
catch(SQLException e2){
e2.getStackTrace();
}
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String number = request.getParameter("No_problem");
String title=request.getParameter("Title_problem");
String describe=request.getParameter("Describe_problem");
String input=request.getParameter("Input_problem");
String output=request.getParameter("Output_problem");

add(number,title,describe,input,output);
return mapping.findForward("error");
}

}
sql="INSERT INTO problem(No,title,describe,input,output)VALUES('"+s1+"','"+s2+"', '"+s3+"','"+s4+"','"+s5+"')";
ResultSet rs= statement.executeQuery(sql);

这什么啊 你执行的插入语句 怎么能用绝森executeQuery呢
Query这个词是查询的意思啊

executeUpdate(String sql)
执行给定 SQL 语句,该语句可能为 INSERT、UPDATE 或 DELETE 语句,或者不返回任何内容的 SQL 语句(如 SQL DDL 语句)。

返回的迹宏搏是int值

ResultSet rs= statement.executeQuery(sql);
while(rs.next())
{
String number = rs.getString("No");
String title = rs.getString("title");
String describe = rs.getString("describe"姿祥);
String input = rs.getString("input");
String output = rs.getString("output");
System.out.print(number);
System.out.print(title);
System.out.print(describe);
System.out.print(input);
System.out.print(output);
}

这统统删掉 根本不返回resultset对象
INSERT INTO problem(No,title,describe,input,output)VALUES

问模改题主要出现在这句,这里面的No和describe都是关键字,所以必须换成其老码段他侍誉非关键字。
建议行纯,你这种插迟稿入的话用prepareStatement做参数的设置,以防止过档旦咐多的字符串拼接。
还有你执行时用的是executeQuery
这是执行select语句时用的。你用execute()试试
ResultSet rs= statement.executeQuery(sql);
这是执行查询的函数吵谈
而你的sql是插入语句带笑
还有你的sql语句也蠢碰含不对