这个是添加jsp页面的查询按钮,我把三者的代码写好后,链接相应出现了以下的错误~~
数据库回滚处理失败,出现此错误时,请您与系统管理员联系。
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '>='2007-09-01'' at line 1 原因在何处呢??

解决方案 »

  1.   

    request.setCharacterEncoding("gb2312");
                ArrayList<String> tiaojianList = new ArrayList<String> ();//查询条件列表
                
                String temp = DBAcc.dealSQLChar(request.getParameter("fromDate"));
                if (temp!=null&&!temp.equals("")){
                    tiaojianList.add("conference_begindate>='"+temp+"'");
                }
                temp = DBAcc.dealSQLChar(request.getParameter("toDate"));
                if(temp!=null&&!temp.equals("")){
                    tiaojianList.add("conference_enddate<='" + temp + "'");
                }
                temp = DBAcc.dealSQLChar(request.getParameter("conference_name"));
                if(temp!=null && !temp.equals("")){
                    tiaojianList.add("conference_name like '%" + temp + "%'");
                }
                temp = DBAcc.dealSQLChar(request.getParameter("conference_lead"));
                if(temp!=null && !temp.equals("")){
                    tiaojianList.add("conference_lead='" + temp + "'");
                }
                temp = DBAcc.dealSQLChar(request.getParameter("conference_person"));
                if(temp!=null && !temp.equals("")){
                    tiaojianList.add("conference_person='" + temp + "'");
                }     
                model = new Bean_searchFile_p12();
                request.getSession().removeAttribute("p12_viewFileList_idList");//清理session中的记录
                Bean_multiPageControl allList = null;
                ArrayList<Hashtable<String, String>> result = null;
                try{
                allList = new Bean_multiPageControl(model.getFileIdList(tiaojianList));
                
                request.getSession().setAttribute("p12_viewFileList_idList",allList);
                if(allList.getPageCount() > 0){
                    result = model.getRecordAt(allList.getIdAtPageX(1));
                }
                Log.writeInfoToDB(userInfo.getId(),"会议通知管理,查找文件,条件:"+tiaojianList.toString().replace("'",""),"成功");
                request.setAttribute("viewFileList_result", result);
                request.setAttribute("thisPage", "1");
                request.setAttribute("maxPage", ""+allList.getPageCount());
                RequestDispatcher rd = request.getRequestDispatcher("/p12_viewFileList.jsp");
                rd.forward(request,response);
                return;
            }catch(ComExc e){
                e.turnToErroPage(request, response);
                return;
            }
            
        }               
    }
    这个是selvet的代码
      

  2.   

    ArrayList<String> getFileIdList(ArrayList<String> tiaojianList) throws ComExc{
            
             ArrayList<String> returnList = new ArrayList<String>();
            int tjLength = tiaojianList.size();
            DBAcc comAcc = new DBAcc();
            
            try {
                comAcc.setDbOC(true, 1);
                String sql = "SELECT id FROM " + Config.DBName
                        + ".ecid_hytz_zj where";
                if (tjLength>=1){
                    sql +=tiaojianList.get(0);
                    for (int i=1;i<tjLength;i++){
                        sql+= " AND "+tiaojianList.get(i);
                    }
                }
               
               
                
                comAcc.doDbSearch(sql); 
                ResultSet rs = comAcc.getResult();
                while (rs.next()) {
                    String id = rs.getString("id");
                    if (id == null){
                        id = "";
                    }
                    returnList.add(id);
                }
                rs.close();
            } catch (SQLException sqlEx) {
                ComExc comEx = new ComExc("Bean_searchFile_p12", "getFileList", "E_001",
                        ComErr.E_001, sqlEx.getMessage());
                throw comEx;
            } catch (ComExc comEx) {
                throw comEx;
            } finally { 
                try {
                    comAcc.setDbOC(false, 0);
                } catch (ComExc comEx) {
                    throw comEx;
                }
            }
            return returnList;
        }
        
        ArrayList<Hashtable<String, String>> getRecordAt(ArrayList<String> idList) throws ComExc{        ArrayList<Hashtable<String, String>> returnList;
            if (idList==null||idList.size()==0){
                return new ArrayList<Hashtable<String, String>>();
            }
            String[] names = {"id","conference_name","conference_begindate","conference_enddate",
                    "conference_lead","conference_person","conference_place","hy_warning_days","conference_content","whether_warning"
                             };
            DBAcc comAcc = new DBAcc();
            
            try {
                comAcc.setDbOC(true, 1);
                String sql = "SELECT * FROM " + Config.DBName
                        + ".ecid_hytz_zj WHERE id IN ('"+idList.get(0)+"'";
                int idLength = idList.size();
                for (int i=1;i<idLength;i++){
                    sql+=", '"+idList.get(i)+"'";
                }
                sql+=")ORDER BY id DESC";
                comAcc.doDbSearch(sql); 
                ResultSet rs = comAcc.getResult();
                returnList = Bean_multiPageControl.getRecordAt(names, rs);
                
            } catch (ComExc comEx) {
                throw comEx;
            } finally { 
                try {
                    comAcc.setDbOC(false, 0);
                } catch (ComExc comEx) {
                    throw comEx;
                }
            }
            
            return returnList;
        }}
    这个是bean的!