多半你执行添加、删除数据记录的SQL语句后,赋值给了RecordSet对象:
RecordSet rs=stmt.executeQuery("insert into ..") 这样是不对的。没看见你的代码,上述只是错误产生的可能性

解决方案 »

  1.   

    并没有上述的问题,附源代码,我检查过,没有发现任何问题。<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"%> 
    <%@ include file="../Connections/FTS.jsp" %>
    <%
    // *** Edit Operations: declare variables// set the form action variable
    String MM_editAction = request.getRequestURI();
    if (request.getQueryString() != null && request.getQueryString().length() > 0) {
      MM_editAction += "?" + request.getQueryString();
    }// connection information
    String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;// redirect information
    String MM_editRedirectUrl = null;// query string to execute
    StringBuffer MM_editQuery = null;// boolean to abort record edit
    boolean MM_abortEdit = false;// table information
    String MM_editTable = null, MM_editColumn = null, MM_recordId = null;// form field information
    String[] MM_fields = null, MM_columns = null;
    %>
    <%
    // *** Update Record: set variablesif (request.getParameter("MM_update") != null &&
        request.getParameter("MM_recordId") != null) {  MM_editDriver     = MM_FTS_DRIVER;
      MM_editConnection = MM_FTS_STRING;
      MM_editUserName   = MM_FTS_USERNAME;
      MM_editPassword   = MM_FTS_PASSWORD;
      MM_editTable  = "dbo.file_type_info";
      MM_editColumn = "id";
      MM_recordId   = "" + request.getParameter("MM_recordId") + "";
      MM_editRedirectUrl = "viewFileType.jsp";
      String MM_fieldsStr = "name|value|description|value";
      String MM_columnsStr = "name|',none,''|description|',none,''";  // create the MM_fields and MM_columns arrays
      java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|");
      MM_fields = new String[tokens.countTokens()];
      for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken();  tokens = new java.util.StringTokenizer(MM_columnsStr,"|");
      MM_columns = new String[tokens.countTokens()];
      for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken();  // set the form values
      for (int i=0; i+1 < MM_fields.length; i+=2) {
        MM_fields[i+1] = new String(((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):"").getBytes("ISO8859_1"), "GB2312");
      }  // append the query string to the redirect URL
      if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
        MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
      }
    }
    %>
    <%
    // *** Delete Record: construct a sql delete statement and execute itif (request.getParameter("MM_delete") != null &&
        request.getParameter("MM_recordId") != null) {  MM_editDriver     = MM_FTS_DRIVER;
      MM_editConnection = MM_FTS_STRING;
      MM_editUserName   = MM_FTS_USERNAME;
      MM_editPassword   = MM_FTS_PASSWORD;
      MM_editTable = "dbo.file_type_info";
      MM_editColumn = "id";
      MM_recordId = "" + request.getParameter("MM_recordId") + "";
      MM_editRedirectUrl = "viewFileType.jsp";  // append the query string to the redirect URL
      if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
        MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
      }
    }
    %>
    <%
    // *** Update Record: construct a sql update statement and execute itif (request.getParameter("MM_update") != null &&
        request.getParameter("MM_recordId") != null) {  // create the update sql statement
      MM_editQuery = new StringBuffer("update ").append(MM_editTable).append(" set ");
      for (int i=0; i+1 < MM_fields.length; i+=2) {
        String formVal = MM_fields[i+1];
        String elem;
        java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],",");
        String delim    = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
        String altVal   = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
        String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:"";
        if (formVal.length() == 0) {
          formVal = emptyVal;
        } else {
          if (altVal.length() != 0) {
            formVal = altVal;
          } else if (delim.compareTo("'") == 0) {  // escape quotes
            StringBuffer escQuotes = new StringBuffer(formVal);
            for (int j=0; j < escQuotes.length(); j++)
              if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\'');
            formVal = "'" + escQuotes + "'";
          } else {
            formVal = delim + formVal + delim;
          }
        }
        MM_editQuery.append((i!=0)?",":"").append(MM_columns[i]).append(" = ").append(formVal);
      }
      MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
      
      if (!MM_abortEdit) {
        // finish the sql and execute it
        Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
        Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();    // redirect with URL parameters
        if (MM_editRedirectUrl.length() != 0) {
          response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
        }
      }
    }
    %>
    <%
    // *** Delete Record: construct a sql delete statement and execute itif (request.getParameter("MM_delete") != null &&
        request.getParameter("MM_recordId") != null) {  // create the delete sql statement
      MM_editQuery = new StringBuffer("delete from ").append(MM_editTable);
      MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);
      
      if (!MM_abortEdit) {
        // finish the sql and execute it
        Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
        Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();    // redirect with URL parameters
        if (MM_editRedirectUrl.length() != 0) {
          response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
        }
      }
    }
    %>
    <%
    String manage_file_type_info__MMColParam = "1";
    if (request.getParameter("id") !=null) {manage_file_type_info__MMColParam = (String)request.getParameter("id");}
    %>
    <%
    Driver Drivermanage_file_type_info = (Driver)Class.forName(MM_FTS_DRIVER).newInstance();
    Connection Connmanage_file_type_info = DriverManager.getConnection(MM_FTS_STRING,MM_FTS_USERNAME,MM_FTS_PASSWORD);
    PreparedStatement Statementmanage_file_type_info = Connmanage_file_type_info.prepareStatement("SELECT *  FROM dbo.file_type_info  WHERE id = " + manage_file_type_info__MMColParam + "");
    ResultSet manage_file_type_info = Statementmanage_file_type_info.executeQuery();
    boolean manage_file_type_info_isEmpty = !manage_file_type_info.next();
    boolean manage_file_type_info_hasData = !manage_file_type_info_isEmpty;
    Object manage_file_type_info_data;
    int manage_file_type_info_numRows = 0;
    %>
      

  2.   

    <html>
    <head>
    <!-- #BeginEditable "doctitle" --> 
    <title>文件管理</title>
    <!-- #EndEditable -->
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <link rel="stylesheet" href="../Templates/fts" type="text/css">
    </head>
    <body bgcolor="#FFFFFF" text="#000000"><!-- #BeginEditable "context" --> 
          <table width="100%" border="0" cellspacing="2" cellpadding="2">        <tr> 
              <td colspan="2"> 
                <hr width="95%">
                <table width="100%" border="0" cellspacing="2" cellpadding="2" class="fts-context">
                  <tr> 
                    <td width="10%" align="right" valign="top">功能:</td>
                    <td align="left"> 
                      <p>1.在 SQL Server 2000 数据库中,更新或删除文件类型数据;</p>
                      <p>2.类型管理页,只能对一个文件类型进行更新或删除,因此不能直接联接;</p>
                      <p>3.Update:更新数据;Reset:初始数据;Delete:删除类型。</p>
                    </td>
                  </tr>
                  <tr> 
                    <td width="10%" align="right" valign="top">帮助:</td>
                    <td align="left"> 
                      <p>1.添加数据至 file_type_info 表;</p>
                      <p>2.表数据段:(<b>id</b>:int(4), name:nvarchar(100), description:nvarchar(1000));</p>
                      <p>3.数据段 id 为标示键,其值自动生成,不需要手工添加;</p>
                    </td>
                  </tr>
                </table>
                <hr width="95%">
                <table width="100%" border="0" cellspacing="2" cellpadding="2">
                  <tr> 
                    <td width="15%" align="right" valign="top" class="fts-context" rowspan="2">类型管理:</td>
                    <td> 
                      <form name="UpdateFileType" method="POST" action="<%=MM_editAction%>">
                        <table width="100%" border="0" cellspacing="2" cellpadding="2" class="fts-context">
                          <tr> 
                            <td width="20%" align="right">&nbsp;</td>
                            <td>更新记录</td>
                          </tr>
                          <tr> 
                            <td align="right" width="20%">文件类型编号:</td>
                            <td><%=(((manage_file_type_info_data = manage_file_type_info.getObject("id"))==null || manage_file_type_info.wasNull())?"":manage_file_type_info_data)%></td>
                          </tr>
                          <tr> 
                            <td align="right" width="20%">文件类型名称:</td>
                            <td> 
                              <input type="text" name="name" size="50" maxlength="100" value="<%=(((manage_file_type_info_data = manage_file_type_info.getObject("name"))==null || manage_file_type_info.wasNull())?"":manage_file_type_info_data)%>">
                            </td>
                          </tr>
                          <tr> 
                            <td align="right" width="20%">文件类型描述:</td>
                            <td> 
                              <input type="text" name="description" size="50" maxlength="1000" value="<%=(((manage_file_type_info_data = manage_file_type_info.getObject("description"))==null || manage_file_type_info.wasNull())?"":manage_file_type_info_data)%>">
                            </td>
                          </tr>
                          <tr> 
                            <td colspan="2" align="center"> 
                              <input type="submit" name="Submit" value="Submit">
                              <input type="reset" name="Reset" value="Reset">
                            </td>
                          </tr>
                        </table>
                        <input type="hidden" name="MM_update" value="true">
                        <input type="hidden" name="MM_recordId" value="<%=(((manage_file_type_info_data = manage_file_type_info.getObject("id"))==null || manage_file_type_info.wasNull())?"":manage_file_type_info_data)%>">
                      </form>
                      <form name="DeleteFileType" method="POST" action="<%=MM_editAction%>">
                        <table width="100%" border="0" cellspacing="2" cellpadding="2" class="fts-context">
                          <tr> 
                            <td width="20%">&nbsp;</td>
                            <td>删除记录</td>
                          </tr>
                          <tr align="center"> 
                            <td colspan="2"> 
                              <input type="submit" name="Delete" value="Delete">
                            </td>
                          </tr>
                        </table>
                        <input type="hidden" name="MM_delete" value="true">
                        <input type="hidden" name="MM_recordId" value="<%=(((manage_file_type_info_data = manage_file_type_info.getObject("id"))==null || manage_file_type_info.wasNull())?"":manage_file_type_info_data)%>">
                      </form>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
          <!-- #EndEditable --></body>
    </html>
    <%
    manage_file_type_info.close();
    Connmanage_file_type_info.close();
    %>
      

  3.   


        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();改成:
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
       MM_editStatement.close();
        MM_connection.close();    PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();改成
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
     MM_editStatement.close();
        MM_connection.close();
    这回试一下。
    如果不行在这样试一下
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();改成:
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.execute();
       MM_editStatement.close();
        MM_connection.close();    PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.executeUpdate();
        MM_connection.close();改成
        PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
        MM_editStatement.execute();
     MM_editStatement.close();
        MM_connection.close();
      

  4.   

    jdbc驱动程序是什么?jdbc_odbc桥吗?换专用的试试。