日期:2014-05-17  浏览次数:20654 次

Can not issue data manipulation statements with executeQuery().JAVA WEB 求助
request.setCharacterEncoding("UTF-8");
  String id=request.getParameter("id");
  String name=request.getParameter("name");
  System.out.println(name);
  String age=request.getParameter("age");
  String gender=request.getParameter("gender");
  String major=request.getParameter("major");
   
  Connection conn=null; 
  Statement stmt=null; 
  ResultSet rs=null;
  Class.forName("com.mysql.jdbc.Driver"); 
  String url="jdbc:mysql://localhost:3306/orcl"; 
  String user="root"; 
  String password="root"; 
  conn=DriverManager.getConnection(url,user,password); 
  stmt=conn.createStatement(); 
  rs=stmt.executeQuery("insert into student (id,name,age,gender,major)values("+id+"','"+name+"','"+age+",'"+gender+"','"+major+")");%>
  把executeQuery改成executeUpdate也不行 因为要返回一个ResultSet

------解决方案--------------------
你的数据表student的字段和类型给出来,这个会影响插入的语法是否正确

论坛这种速度太慢 519582737 加QQ

探讨
引用:
报错是 严重: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
at com.mysql.jdbc.SQLError.……