你只是测试了你的executeQuery()方法,而你jsp中用的是executeUpdate()方法
你仔细测测可能会发现原因

解决方案 »

  1.   

    我就是要运行executeUpdate()这个方法拉,我逻辑上是没有错拉,
    不行就是这个方法executeUpdate()我只是说明点executeQuery()我这个方法是没有错的。
      

  2.   

    update好像必须有返回值的你的update执行语句这样写一下:
    sql=" update tb_user set name='xishui' where name='xishuichi'";int col=stmt.executeUpdate(sql);
      

  3.   

    不好意思 拉写了1句Statement stmt=conn.createStatement();sql=" update tb_user set name='xishui' where name='xishuichi'";int col=stmt.executeUpdate(sql);
      

  4.   

    不可以拉!!! warehouseleet(堆栈.net)
    我的conn是bean引进来的。。
      

  5.   

    不是 你理解错了,我的意思不是你用什么方式连接的库,而是要UPDATE的话,它一定要有返回值的,而且是 int形的!!明白了么???
      

  6.   

    你的不可以 warehouseleet(堆栈.net)
      

  7.   

    你定义记录集对象了么?Statement pstmt=conn.createStatement();
      

  8.   

    你把stmt.executeUpdate(sql);换一下,使用stmt.execute(sql);
    试一下看看!
      

  9.   

    你应该生成statement变量,调用executeUpdate()
      

  10.   

    我用了,statement stmt=executeUpdate(sql); 
     还是出这样的错误
       org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    那大侠真的要帮帮小弟我都帖出两天了,还没解决问题啊 .拜托!!1
      

  11.   

    public void executeUpdate(String sql) throws Exception
    试下把throws Exception删除,看有没有抛出错误
    你这样写statement stmt=executeUpdate(sql); 肯定是错的
    Statement stmt=conn.createStatement();
    sql=" update tb_user set name='xishui' where name='xishuichi'";
    stmt.executeUpdate(sql);
      

  12.   

    你的程序我试了一下,如果把你bean 里的方法executeQuery()中stm.executeQuery(sql)一句,该成int t=stm.executeQuery(sql),在我机器上是可以使用的。
    jsp*******************************
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head>
    <body>
    <jsp:useBean id="conn" scope="page" class="opendb.opendb"/><%
     String sql;
     try{
      sql=" update message set name='b' where name='a'";
      conn.executeUpdate(sql);
     }
     catch(Exception e)
     {
     System.out.println(e.getMessage());
     } %></body>
    </html>
    bean******************************
    package opendb;
    import java.sql.*;
    public class opendb
    {
    String sdbdirver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=newdate";
        String user="sa";
        String password="sa";
    Connection conn=null;
    ResultSet rs=null;

    public opendb()
    {
     try{
      Class.forName(sdbdirver);
     
     }
     catch(java.lang.ClassNotFoundException e){
      System.err.println("opendb():"+e.getMessage());
     }
       
        }
        public ResultSet executeQuery(String sql) throws Exception
         {  
         try{
            sql= new String(sql.getBytes("GBK"),"ISO8859_1");
         conn=DriverManager.getConnection(url,user,password);
         Statement stmt=conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
            rs=stmt.executeQuery(sql); 
            }
           catch(SQLException ex)
            {
           System.out.println("executeQuery(sql)"+ex.getMessage());
            }
            return rs;
         }
         public void executeUpdate(String sql) throws Exception
         {   
          sql= new String(sql.getBytes("GBK"),"ISO8859_1");
          try{
          conn=DriverManager.getConnection(url,user,password);   
          Statement stmt=conn.createStatement();
               int t=stmt.executeUpdate(sql);
          }
          catch(SQLException ex){
          System.out.println("executeUpdate(sql)"+ex.getMessage());      }
         }
         
    }