💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 /** * <b>方法描述:</b> 数据批量插入 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-08 17:39:04 <br/> * * @param poolName * 入参|数据源,为空使用默认|{@link java.lang.String} * @param tableName * 入参|表名String|{@link java.lang.String} * @param column * 入参|column 新增列项JavaList,如:["COL","COL2",...]| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @param values * 入参|新增列内容javaList * 如:[["value1","value2",...],["value1","value2",...]]"| * {@link com.ylink.ide.trade.runtime.context.JavaList} * @param commitFlg * 入参|提交标识Boolean|{@link boolean} * @param num * 入参|每num条执行一次插入|{@link int} * @param rows * 出参|执行插入影响的条数int|{@link int} * @return -1 异常<br/> * 0 失败<br/> * 1 成功<br/> */ @Component(label = "数据批量插入", style = "判断型", type = "同步组件", comment = "用预编译的方式登记数据到数据库中,column 和 values 传入的值要一一对应", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-08 05:39:04") @InParams(param = { @Param(name = "poolName", comment = "数据源,为空使用默认", type = java.lang.String.class), @Param(name = "tableName", comment = "表名String", type = java.lang.String.class), @Param(name = "column", comment = "column 新增列项JavaList,如:['COL','COL2',...]", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "values", comment = "新增列内容javaList 如:[['value1','value2',...],['value1','value2',...]]'", type = com.ylink.ide.trade.runtime.context.JavaList.class), @Param(name = "commitFlg", comment = "提交标识Boolean", type = boolean.class), @Param(name = "num", comment = "每num条执行一次插入", type = int.class) }) @OutParams(param = { @Param(name = "rows", comment = "执行插入影响的条数int", type = int.class) }) @Returns(returns = { @Return(id = "-1", desp = "异常"), @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase P_preparedBatchInsert(String poolName, String tableName, JavaList column, JavaList values, boolean commitFlg, int num) { try { int rowS = JdbcUtil.preparedBatchInsert(poolName, tableName, column, values, commitFlg, num); if (rowS > 0) { return ResultBase.newSuccessResult(rowS); } else { return ResultBase.newFailureResult("TPTJ0016", "数据批量插入 执行成功0条"); } } catch (Exception e) { AppLog.error(e); return ResultBase.newExceptionResult("TPTJ0017", "数据批量插入 异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/b0/32/b032db83fed6cd1f8fa8d023fbef722d_1702x1244.png) 数据源的来源为项目的配置文件中的数据源,以及前端页面上的数据源管理列表中添加的数据源 ## 参数说明及示例 表名String:数据库表名,示例: `"sys_user"` column 新增列项JavaList:新增时给这些字段插入值,需要填入集合,示例: `["name","age"]` 新增列内容javaList:新增的数据值集合,示例: `[["张三","53"],["李四","37"]]` 提交标识Boolean:是否进行数据库提交,示例: `true` 每num条执行一次插入:每多少条执行一次插入操作,示例: `1` 执行插入影响的条数int:一共插入了多少条数据,示例: `__INNER__["num"]` > 注意:填写值如果是String字符串,则需要在前后加上英文双引号"",如果是数字或者boolean值,则不需要