🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 组件源码 /** * <b>方法描述:</b> 预编译SQL查询(参数) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-03-28 15:00:26 <br/> * * @param poolName * 入参|数据源,为空使用默认|{@link java.lang.String} * @param sqlcmd * 入参|预编译查询sql语句String,可以含?|{@link java.lang.String} * @param values * 入参|SQL语句中?的值JavaList,列中的值顺序要和?的位置对应,如:[VAL1,VAL2...]| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @param rownum * 入参|需要获取的数据笔数int|{@link int} * @param num * 出参|查询到的行数int|{@link int} * @param result * 出参|所有的行数据list| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @return -1 异常<br/> * 0 失败<br/> * 2 无数据<br/> * 1 成功<br/> */ @Component(label = "预编译SQL查询(参数)", style = "判断型", type = "同步组件", comment = "根据sql查询语句获取查询的数据,默认是取所有,可以指定需要获取的行数,list中存放查询到的笔数和数据,格式为:[笔数,所有行的list]", version = "1.0.0", deprecated = false, author = "admin", date = "2019-03-28 03:00:26") @InParams(param = { @Param(name = "poolName", comment = "数据源,为空使用默认", type = java.lang.String.class), @Param(name = "sqlcmd", comment = "预编译查询sql语句String,可以含?", type = java.lang.String.class), @Param(name = "values", comment = "SQL语句中?的值JavaList,列中的值顺序要和?的位置对应,如:[VAL1,VAL2...]", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "rownum", comment = "需要获取的数据笔数int", type = int.class) }) @OutParams(param = { @Param(name = "num", comment = "查询到的行数int", type = int.class), @Param(name = "result", comment = "所有的行数据list", type = com.ylink.ide.trade.runtime.context.JavaList.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "2", desp = "无数据"), @Return(id = "1", desp = "成功") }) public static ResultBase P_preparedSelect(String poolName, String sqlcmd, JavaList values, int rownum) { try { JavaList jList = JdbcUtil.preparedSelect(poolName, sqlcmd, values, rownum); if (jList.size() == 0) { return new ResultBase(2); } else { int size = jList.size(); return ResultBase.newSuccessResult(size, jList); } } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTJ0010", "SQL查询(参数) 异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/ae/a4/aea4a3053a9eb856a9bbb6c25de5f250_1694x1120.jpg) 数据源的来源为项目的配置文件中的数据源,以及前端页面上的数据源管理列表中添加的数据源 ## 参数说明及示例 预编译查询sql语句String,可以含?:在里面填写可执行的预编译sql语句,示例: `"select * from sys_user where name = ? and age < ?"` SQL语句中?的值JavaList,列中的值顺序要和?的位置对应:对应sql语句中?的值,根据数据库的字段类型正确填写对应的字段值,示例: `["张三", 47]` 需要获取的数据笔数int:需要获取的数据条数,示例: `3` 查询到的行数int:查询到的数据条数,示例: `__INNER__["totle"]` 所有的行数据list:填写true或者false,示例: `__INNER__["result"]`