"); out.println("********导出完毕!********
"); } } catch (Exception e) { } %> <%! private static String strAppID = "1"; private static String[] colsname = { "信息标题", "创建日期","用户帐号","关键字","作者","来源", "摘要","录入人","审核人","链接网址","截止日期","评论","信息备注","发布时间","文号","正文","附件","统一编码"}; private static String basicPath = "J:/数据测试/源数据/"; private static int infoCount = 0; //导出信息总数s private static int cataCount = 0; //有信息的栏目数 private static String cataInfo = ""; //有信息栏目的ID集合 private static String infoEachNum = ""; //有信息栏目的信息数 private static int totalPage = 0; //xml个数 private static int totalNum = 0; //信息总数 private static int eachPage = 1000; //每个xml的信息条数 private static int xmlIndex = 0; //xml计数 private static int beginIndex = 0; //开始写的信息index private static int endIndex = 0; //结束信息index private static String path = ""; public static void writexml() { String infoSql= "select count(1) from jcms_info where i_webid = 2678 and i_cataid = 1345533"; WebInformationDAO webDao = SpringUtil.getBean(WebInformationDAO.class); Query query = webDao.createQuery(infoSql); int total = webDao.queryForInteger(query); int pageno = 0; if(total/300 == 0){ pageno = total%300; }else{ pageno = total%300 + 1; } for(int p = 0; p < pageno;p++){ /*"信息标题", "创建日期","用户帐号","关键字","作者","来源", "摘要","录入人","审核人","链接网址","截止日期","评论","信息备注","发布时间","文号","正文","附件","统一编码"*/ infoSql= "select i_id, vc_title,c_createdate,‘‘,vc_keyword,vc_author,vc_source,vc_describe,vc_editor,‘‘,vc_href,‘‘,‘‘,‘‘,"+ "c_complatedate,vc_filenumber,vc_content,vc_attach,vc_sectitle "+ "from jcms_info where i_webid = 2678 and i_cataid = 1345533 LIMIT "+p*1000+","+1000; CatalogInfoDAO cataDao = SpringUtil.getBean(CatalogInfoDAO.class); query = cataDao.createQuery(infoSql); System.out.println( "**************infoSql**********" + infoSql); String[][] strDatas = cataDao.queryForArrays(query); System.out.println("开始导出,一共有" + strDatas.length + "条信息!"); infoCount += strDatas.length; cataCount++; totalNum = strDatas.length; /* if (totalNum % eachPage == 0) { totalPage = totalNum / eachPage; } else { totalPage = totalNum / eachPage + 1; } */ SysInfo sys = new SysInfo(); Jcms_InfoBLF infoBLF = Jcms_InfoBLF.getInstance().init(sys); Jcms_InfoEntity entity; try { /* for (xmlIndex = 0; xmlIndex < totalPage; xmlIndex++) { */ /* beginIndex = xmlIndex * eachPage; endIndex = (xmlIndex + 1) * eachPage > strDatas.length ? strDatas.length : (xmlIndex + 1) * eachPage; */ StringBuffer sb = new StringBuffer(); sb.append("" + "\r\n"); sb.append(""); //写文件 path =BaseInfo.getRealPath() + "/info/"; //path ="f:/数据测试/目标数据"; String filePath = path + p+"info.xml"; FileOutputStream fos = new FileOutputStream(filePath,false); Writer writer = new OutputStreamWriter(fos, "UTF-8"); writer.write(sb.toString()); sb.delete(0, sb.length()); writer.flush(); writer.close(); /* } */ } catch (Exception e) { e.printStackTrace(); } System.out.println("==============一共导出" + cataCount+ "个栏目=================="); System.out.println("==============一共" + infoCount+ "条信息=================="); } } %>
从数据库查询数据然后拼接成xml文件
标签:cat java out real 审核 正文 false 个数 read