PreparedStatement stmt=conn.preparetatement(sql);修改成
PreparedStatement stmt=conn.prepareStatement(sql);

解决方案 »

  1.   


    public class CheckSQLValue {    /**
         * 传入SQL变量的类型
         */    /* 日期型 */
        public static final int INT_SQLTYPE_DATE = 1;    /* 数值型 */
        public static final int INT_SQLTYPE_NUMBER = 2;    /* 字符型 */
        public static final int INT_SQLTYPE_STRING = 3;    /**
         * SQL 敏感字符
         */
        public static final String[] STR_SQL_CMD = new String[] { "CREATE", "DROP", "ALTER", "INSERT", "DELETE", "UPDATE", "SELECT", "sp_", "EXEC", "OR", "AND" };    /**
         * 检验输入SQL的变量内容 用于限定长度的字符串类型
         */
        public static String checkValueForSQL(String string, int inType, int inMaxLength) throws Exception {        /* 字符串型 */
            if (inType == CheckSQLValue.INT_SQLTYPE_STRING) {            /* 超长则截断字符串 */
                if (string.length() > inMaxLength) {
                    string = string.substring(0, inMaxLength);
                }            /* 进入下一个函数再次过滤 */
                string = checkValueForSQL(string, inType);        }        return string;
        }    /**
         * 检验输入SQL的变量内容
         */
        public static String checkValueForSQL(String string, int inType) throws Exception {
            /* 日期型数值 */
            if (inType == CheckSQLValue.INT_SQLTYPE_DATE) {            /* 检测是否有无效字符 */
                char chTMP = ' ';
                for (int i = 0; i < string.length(); i++) {
                    chTMP = string.charAt(i);
                    if ((chTMP < '0' || chTMP > '9') && chTMP != '-' && chTMP != ' ' && chTMP != ':') {                    /* 存在无效字符 将STRING置空 */
                        string = "";
                        break;
                    }
                }
            }        /* 数值型 */
            if (inType == CheckSQLValue.INT_SQLTYPE_NUMBER) {            /* 检测是否有无效字符 */
                char chTMP = ' ';
                for (int i = 0; i < string.length(); i++) {
                    chTMP = string.charAt(i);
                    if ((chTMP < '0' || chTMP > '9') && chTMP != '-' && chTMP != '+' && chTMP != '.') {                    /* 存在无效字符 将STRING置空 */
                        string = "";
                        break;
                    }
                }
            }        /* 字符串型 */
            if (inType == CheckSQLValue.INT_SQLTYPE_STRING) {            /* 转换单引号 */
                string = string.replaceAll("'", "''");            /* 转换敏感字符 */
                String strUP = string.toUpperCase();
                for (int i = 0; i < STR_SQL_CMD.length; i++) {
                    if (strUP.indexOf(STR_SQL_CMD[i]) != -1) {
                        int inIndex = strUP.indexOf(STR_SQL_CMD[i]);
                        string = string.substring(0, inIndex) + "'+'" + string.substring(inIndex, inIndex + STR_SQL_CMD[i].length()) + "'+'" + string.substring(inIndex + STR_SQL_CMD[i].length(), string.length());
                    }
                }
            }        return string;
        }
    }
      

  2.   

    楼主,建议你看看jsp的基础,这些东西都有的,或者在提问前搜索一下有没有类似的帖子,这样子问效率不高,还浪费分。我只是建议,我也算是新手!
      

  3.   

    PreparedStatement stmt=conn.preparetatement(sql);
    少了个s啊,怎么可能对呢
    Statement
      

  4.   

    String sql="select * from corp_members where user_name=?";
    //PreparedStatement stmt=conn.prepareStatement(sql);
    //stmt.setString(1,user_name);
    //rs=stmt.executeQuery();//这样不行
      

  5.   

    PreparedStatement stmt=conn.prepareStatement(sql);
      

  6.   

    Connection的对象conn的预查询conn.executeQuery(sql);
                          普通查询conn.prepareStatement(sql);细节可参考API,在IDE中也是有预显示功能可看到其方法的
      

  7.   

    建议楼主用Eclipse,JB这样的工具,可以避免犯类似的错误。
      

  8.   

    你没用IDE吧,用WSAD或者JB看看
      

  9.   

    那我下载个下来了吧.我是用dreamweaver的啊.
      

  10.   

    xx.conn 你这个类的内容是什么啊 按照你上面出现的错误 这个类返回的好象是Statement类型 把这个类的源码贴出来
      

  11.   

    dreamweaver开发个人网站,做漂亮的网页还行。但是他不是和用来开发企业级的应用程序的,企业级的应用这方面,dreamweaver太弱了。
      

  12.   

    Eclipse有中文,而且开源
    挺好用
      

  13.   

    现在仅求解决方法.不论什么方法.(防SQL注入式漏洞)
      

  14.   

    现在仅求解决方法.不论什么方法.(防SQL注入式漏洞)