Java 存储过程调用

//配置文件
 private static ClientServiceConfigUtil configUtil = new ClientServiceConfigUtil("/DatabaseConfig.properties");
 
 private static String ConnStr = configUtil.getValue("Database_Url");;//数据库URL
 private static String user=configUtil.getValue("Database_User"); //数据库用户名
    private static String password=configUtil.getValue("Database_Password");//数据库用户密码
    private static String ClassString= configUtil.getValue("Database_DriverClass");//数据库驱动类文件

 

service 调用底层代码  ProcedureParams params = new ProcedureParams(MissionlistVo.PRIC_MISSIONLIST, 3);

 //加入参数 

 params.addParam(1, String.class, userCode);
   params.addParam(2, String.class, twoCode);
   params.addParam(3, String.class, threeCode);

执行封装好的方法list = dao.executeProcedureToList(MissionlistVo.class, params);

 

public <T> List<T> executeProcedureToList(Class<T> returnClass,ProcedureParams params) throws SQLException, SecurityException, NoSuchMethodException,
             IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {   。。。。。。。。。}

底层泛型代码略。。。。。

关键代码 调用存储过程

conn =  getSession().connection();

//   conn.setAutoCommit(false);

   cStmt = conn.prepareCall(params.getCallProcString());
View Code

 

你可能感兴趣的:(java)