posts - 15,  comments - 34,  trackbacks - 27

 

public class AssetFileQueueFixedDAOImpl extends JdbcDaoSupport implements AssetFileQueueDAO{

    
private final static String SELECT="SELECT ID,REGION,IP,FILE_SIZE,OLD_FILE_NAME,NEW_FILE_NAME,FILE_PATH,TEMP_TABLE_NAME,UP_DATE,TOTAL_ASSET,FAILURE_REASON,STATUS FROM ASSET_FILE_QUEUE";
    
    
/**
     * 保存
     
*/

    
public void save(final FileAttributeVO vo){
        String sql
="INSERT INTO ASSET_FILE_QUEUE(REGION,IP,FILE_SIZE,OLD_FILE_NAME,NEW_FILE_NAME,FILE_PATH,TEMP_TABLE_NAME,UP_DATE,STATUS) VALUES(?,?,?,?,?,?,?,sysdate,?)";
        getJdbcTemplate().update(sql,
new PreparedStatementSetter(){

            
public void setValues(PreparedStatement ps) throws SQLException{
                
int i=1;
                ps.setString(i
++,vo.getRegion());
                ps.setString(i
++,vo.getIP());
                ps.setLong(i
++,vo.getFileSize().longValue());
                ps.setString(i
++,vo.getOldFileName());
                ps.setString(i
++,vo.getNewFileName());
                ps.setString(i
++,vo.getFilePath());
                ps.setString(i
++,vo.getTempTabelName());
                ps.setString(i
++,vo.getStatus());
            }

        }
);
    }


    
/**
     * 查询
     
*/

    
public List listFilesByStatus(final String status){
        String sql
=SELECT + " WHERE STATUS=? AND ROWNUM<=10 ORDER BY ID";
        
return (List)getJdbcTemplate().query(sql,new PreparedStatementSetter(){

            
public void setValues(PreparedStatement ps) throws SQLException{
                ps.setString(
1,status);
            }


            
// return result;
            }
,new ResultSetExtractor(){

                List result
=new ArrayList();

                
public Object extractData(ResultSet rs) throws SQLException,DataAccessException{
                    
while(rs.next()){
                        FileAttributeVO vo
=new FileAttributeVO();
                        
int i=1;
                        vo.setId(
new Long(rs.getLong(i++)));
                        vo.setRegion(rs.getString(i
++));
                        vo.setIP(rs.getString(i
++));
                        vo.setFileSize(
new Long(rs.getLong(i++)));
                        vo.setOldFileName(rs.getString(i
++));
                        vo.setNewFileName(rs.getString(i
++));
                        vo.setFilePath(rs.getString(i
++));
                        vo.setTempTabelName(rs.getString(i
++));
                        vo.setUpDate(rs.getString(i
++));
                        vo.setTotalAsset(
new Integer(rs.getInt(i++)));
                        vo.setFailureReason(rs.getString(i
++));
                        vo.setStatus(rs.getString(i
++));
                        result.add(vo);
                    }

                    
return result;

                }

            }
);
    }


    
/**
     * 更新
     
*/

    
public void update(final FileAttributeVO vo){
        String sql
="UPDATE ASSET_FILE_QUEUE SET FAILURE_REASON=?,STATUS=?,TOTAL_ASSET=? where id=?";
        getJdbcTemplate().update(sql,
new PreparedStatementSetter(){

            
public void setValues(PreparedStatement ps) throws SQLException{
                
int i=1;
                ps.setString(i
++,StringUtils.trim(vo.getFailureReason())+"");
                ps.setString(i
++,vo.getStatus());
                
long total=vo.getTotalAsset()==null?0:vo.getTotalAsset().longValue();
                ps.setLong(i
++,total);
                ps.setLong(i
++,vo.getId().longValue());
            }

        }
);
    }


}
posted on 2005-12-29 13:44 jacky 阅读(498) 评论(0)  编辑  收藏 所属分类: Open source

只有注册用户登录后才能发表评论。


网站导航:
 
<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(10)

随笔档案

文章分类

文章档案

相册

收藏夹

java

搜索

  •  

最新评论