日期:2014-05-18  浏览次数:20791 次

数据复制效率问题
我们公司用的sqlservlet2000数据库.需要把远端的一个数据库的一个表里的记录(大约3万条)必须通过java程序复制到我们本地的一个数据库表里.我们做了一个程序.但是整个过程需要30分钟.如果等到这个时间的话,session都无效了.特郁闷!代码如下:
/********取处上大远程数据开始*********************/
public   static   boolean   getSDdata(){
log.info( "get   sddata   begin! ");
      boolean   result=false   ;
      /***上大项目读取数据**/

        try   {
        List   list   =   getStudentBaseInfoService().getStudentBaseInfoList( "select   *   from   StudentBaseInfo   order   by   dept_Id ");
        com.ins.util.StringToDate   getdate=new   com.ins.util.StringToDate();
        //   清空班级人数。
                        String   sql   =   "update   AdminClass   set   rs=0,   fkrs=0 ";
                        getSystemDAO().doUpdate(sql);
                        log.info( "list   size   = "+list.size());
        for(int   i=0;i <list.size();i++)
        {

        log.info( "i= "+i);
        StudentBaseInfo   stt   =   (StudentBaseInfo)list.get(i);
        //String   strinsert   =   "insert   into   temptable   (name)   values( 'ddddd ') ";
        String   xh   =   stt.getPersNo().trim();
        String   xm   =   stt.getPersName().trim();
        Integer   intxb   =   stt.getPersSex().intValue();
        String   kh   =   stt.getIcChipNo().trim();
        String   bjbh   =   stt.getDeptId().trim();
        String   bjmc   =   stt.getDeptName();
        String   csny   =   getdate.getString(getdate.getDate(stt.getBirthd())).trim().substring(0,10);
        Integer   nj   =   stt.getNj().intValue();
        Integer   xz   =   stt.getNz().intValue();        
       
       
        /***以下是向学生表中Insert   into   DATA   BEGIN**/
          //第一步   添加院系.
          //log.info( "第一步   添加院系 ");
                                  College   college   =   null;
                                  List     college1list   =   (List)getCollegeDAO().findByChinese( "FROM   College   c   where   c.yxmc=? ",   "上海大学 ");
          //log.info( "colloege1   =   "+college1list.size());
          &n