标签:
CREATE OR REPLACE PROCEDURE TEST3(TID IN INTEGER,O OUT SYS_REFCURSOR) AS BEGIN IF(TID>0) THEN OPEN O FOR SELECT * FROM XHSCK.T_ADMINISTRATIVE_LEVEL T WHERE T.ADMINISTRATIVE_LEVEL_ID = TID; ELSE OPEN O FOR SELECT * FROM XHSCK.T_ADMINISTRATIVE_LEVEL T WHERE T.ADMINISTRATIVE_LEVEL_ID = 1; END IF; END;
WallFilter wallFilter = new WallFilter(); DruidPlugin druid = new DruidPlugin(getProperty("jdbc.url"), getProperty("jdbc.username"), getProperty("jdbc.password").trim() ,getProperty("jdbc.driver")); druid.addFilter(new StatFilter()); druid.addFilter(wallFilter); //连接池最大使用连接数量 druid.setMaxActive(getPropertyToInt("maxActive",100)); //连接池最小空闲 druid.setMinIdle(getPropertyToInt("minIdle",10)); //初始化大小 druid.setInitialSize(getPropertyToInt("initialSize",10)); druid.start(); Config cfg = new Config("1", druid.getDataSource()); DbKit.addConfig(cfg); List<Record> list = (List<Record>) Db.use("1").execute(new MyCallBack(6,cfg)); System.out.println(list.get(0).getStr("ADMINISTRATIVE_LEVEL_NAME"));
public class MyCallBack implements ICallback { public int tid; public Config cfg; public ResultSet rs = null; MyCallBack(int tid,Config cfg){ this.tid=tid; this.cfg=cfg; } @Override public Object call(Connection conn) throws SQLException { CallableStatement proc = null; proc = conn.prepareCall("{ call test3(?,?) }"); proc.setInt(1, tid); proc.registerOutParameter(2, OracleTypes.CURSOR); proc.execute(); ResultSet s = (ResultSet) proc.getObject(2); List<Record> list = (List<Record>) RecordBuilder.build(cfg, s); return list; } }
标签:
原文地址:http://my.oschina.net/forai/blog/405000