Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1966848
  • 博文数量: 606
  • 博客积分: 9991
  • 博客等级: 中将
  • 技术积分: 5725
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-17 19:07
文章分类

全部博文(606)

文章存档

2011年(10)

2010年(67)

2009年(155)

2008年(386)

分类: Java

2009-11-06 14:56:12

 
1. 存储过程:
文件: procedure.rar
大小: 4KB
下载: 下载
2. spring + hibernate 调用
 
ProcedureMngImpl.java
 

@Service
@Transactional
public class ProcedureMngImpl extends BaseManagerImpl implements ProcedureMng {
    protected Logger log = LoggerFactory.getLogger(getClass());
    
    @Autowired
    public void setDao(ProcedureDao dao) {
        super.setDao(dao);
    }
    
    public ProcedureDao getDao(){
        return (ProcedureDao) super.getDao();
        
    }

    @Override
    public void execImportOrganization() {
        String proc = "{call mrpsWap.dbo.spUUM_ImportOrganization()}";
        execProcedure(proc);
    }

    @Override
    public void execImportUser() {
        String proc = "{call mrpsWap.dbo.spUUM_ImportUser()}";
        execProcedure(proc);
    }

}

ProcedureDaoImpl.java 

public void execProcedure(String proc) {
        Session s = null;
        Connection conn = null;
        CallableStatement st = null;
        try {
            s = getSession();
            conn = s.connection();
            st = conn.prepareCall(proc);
            st.execute();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (st != null)
                    st.close();
                if (conn != null)
                    conn.close();
            } catch (SQLException e) {
                log.error(e.getMessage());
                e.printStackTrace();
            }
        }
    }


阅读(706) | 评论(0) | 转发(0) |
0

上一篇:xfire生成web服务客户端

下一篇:java socket

给主人留下些什么吧!~~