您的位置:首页 > 数据库 > Oracle

jdbc存储过程示例

2017-01-12 19:58 211 查看
create or replace procedure getNewsCount(v_totalCount out number) is

begin

  SELECT COUNT(*) INTO v_totalCount FROM news_detail;

end getNewsCount;

    //获取新闻总数(执行存储过程)

    public int getTotalCountProc(){

        int totalCount=0;

        CallableStatement proc=null;

        String sql="{call getNewsCount(?)}";

        getConnection();

        try {

            proc=conn.prepareCall(sql);

            proc.registerOutParameter(1, Types.INTEGER);

            proc.execute();

            totalCount=proc.getInt(1);

        } catch (SQLException e) {

            

            e.printStackTrace();

        }finally{

            if(proc!=null)

                try {

                    proc.close();

                } catch (SQLException e) {

                    

                    e.printStackTrace();

                }

        

        

        }

        return totalCount;

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  存储 jdbc class oracle plsql