当前位置:网站首页>JDBC connection pool is used for batch import. 5million data are run each time, but various problems will occur in the middle
JDBC connection pool is used for batch import. 5million data are run each time, but various problems will occur in the middle
2022-06-11 13:11:00 【CSDN Q & A】
I wrote a JDBC Connection pool for batch import , Each run 500 All the data , But in the middle there will be various problems
problem 1:The last packet successfully received from the server was 18,967 milliseconds ago. The last packet sent successfully to the server was 18,963 milliseconds ago.
For question 1 The default time is 8 Hours , I just started the project , Can't run 30 minute , How can the connection expire ? What the Internet says to change out Time , I also changed the invalid ? Just looking at this time, I don't think it's what the Internet says ?
problem 2: Cut a picture to see the picture

problem 3: It is also an error reported when submitting ;
The code is also posted , Each error is reported when submitting ,ps.executeBatch();;
```java private void saveForecastSales(List<ForecastSalesDO> forecastSalesDOS, int count) { try { if (count > 2) { log.info("JDBCOperationServiceImpl->saveForecastSales:: Two attempts failed "); return; } Connection connection = dbPool.getConnection(); if (!connection.isValid(1000)){ dbPool.removeConnection(connection); log.error("JDBCOperationServiceImpl->saveForecastSales::connection "); connection = DbUtil.createConnection(); } PreparedStatement ps = connection.prepareStatement(JDBCUtils.SQL); connection.setAutoCommit(false); forecastSalesDOS.forEach(e -> { try { ps.setObject(1, e.getSku()); ps.setObject(2, e.getErpSku()); ps.setObject(3, e.getSite()); ps.setObject(4, e.getMarketId()); ps.setObject(5, DateUtil.getMinusHours(e.getPaidTime())); ps.setObject(6, e.getAmount()); ps.setObject(7, e.getPlatformId()); ps.setObject(8, e.getOrderType()); ps.setObject(9, e.getOrderCategory()); ps.setObject(10, e.getAsin()); ps.setObject(11, e.getIdealWarehouse()); ps.setObject(12, e.getActualFreight()); ps.setObject(13, e.getActualWarehouse()); ps.setObject(14, e.getCountry()); ps.setObject(15, e.getSimulatedNetProfit()); ps.setObject(16, e.getOrderTotalPrice()); ps.setObject(17, e.getOrderCode()); ps.setObject(18, e.getOrderCurrency()); ps.setObject(19, DateUtil.getMinusHours(e.getOrderCreatedTime())); ps.setObject(20, e.getOrderSn()); ps.setObject(21, e.getFreight()); ps.setObject(22, e.getUnitPrice()); ps.setObject(23, e.getIsFba()); ps.setObject(24, DateUtil.getMinusHours(e.getCreatedTime())); ps.setObject(25, e.getCreatedBy()); ps.setObject(26, DateUtil.getMinusHours(e.getUpdatedTime())); ps.setObject(27, e.getUpdatedBy()); ps.setObject(28, e.getIsDelete()); ps.addBatch();// ps.clearParameters(); } catch (SQLException throwables) { log.info(" Inner layer :JDBCOperationServiceImpl->batchForecastSales: abnormal ,{}", throwables.getMessage()); throw new RuntimeException(throwables); } }); DbUtil.executeBatchInsert(connection, ps); dbPool.releaseConnection(connection); } catch (SQLException throwables) { throwables.printStackTrace(); log.info(" Outer layer :JDBCOperationServiceImpl->batchForecastSales: abnormal ,SQLException::{}", throwables.getMessage()); count++; log.info(" Trying :::::"); this.saveForecastSales(forecastSalesDOS, count); } }public static void executeBatchInsert(Connection connection, PreparedStatement ps) throws SQLException { if(ps==null){ log.info("executeBatchInsert-> It's empty "); } ps.executeBatch(); connection.commit(); ps.clearBatch(); closePs(ps);}```
边栏推荐
- Shader shader
- Deep learning and CV tutorial (14) | image segmentation (FCN, segnet, u-net, pspnet, deeplab, refinenet)
- Which brand of bone conduction Bluetooth headset is good? Five most popular bone conduction Bluetooth headsets
- [acwing 11. solution number of knapsack problem] 01 knapsack + 01 knapsack + understand the specific meaning of 01 knapsack
- 【增加功能】select下拉多选 显示选中的人员
- Live share experience
- . The way to prove the effect of throwing exceptions on performance in. Net core
- Add function drop-down multiple selections to display the selected personnel
- The end of an era! After ten years, Wu Enda's classic machine learning course closed its registration this month and launched a new course
- [clearos] install the clearos system
猜你喜欢
![[bug resolution] the form is paged to display the total data res.data total](/img/92/1ddde16d35465f8dd53ebf90e249b8.png)
[bug resolution] the form is paged to display the total data res.data total

Log management system, summary in multiple ways

Tawang food industry insight | China's dairy market analysis, competition pattern, development trend and thinking

openharmony标准系统移植之音频适配

Adobe Premiere foundation - batch material import sequence - variable speed and rewind (recall) - continuous action shot switching - subtitle requirements (13)

【信号去噪】基于稀疏性 (BEADS) 实现色谱基线估计和去噪附matlab代码和论文
![[ArcGIS]城市关联度分析](/img/f4/454266e1ed586240bce9a7f36aa52e.png)
[ArcGIS]城市关联度分析

网络信息系统应急响应

Zhongfu Jinshi: with the rapid development of the intelligent bathroom industry, the intelligent toilet will usher in a highlight moment

App manual signature of openharmony standard system
随机推荐
一个时代的终结!十年了吴恩达经典《机器学习》课程本月关闭注册,上线新课!...
/usr/bin/gzip: 1: ELF: not found /usr/bin/gzip: 3: : not found /usr/bin/gzip: 4: Syntax erro
Add environment path
深度学习与CV教程(14) | 图像分割 (FCN,SegNet,U-Net,PSPNet,DeepLab,RefineNet)
The end of an era! After ten years, Wu Enda's classic machine learning course closed its registration this month and launched a new course
ASCII, Unicode, and UTF-8
openharmony标准系统移植之音频适配
@Controller和RequestMapping如何解析的
启封easy QF PDA帮助企业提升ERP的管理水平
jdbctemplate数据后台管理,不知道为什么添加用户的时候显示roleId为空
關於分布式鎖的續命問題——基於Redis實現的分布式鎖
How does Cassandra, an open source database giant, tell a "new story" in China? Face to face
【bug解决】表单分页,显示总数据res.data.total
Imx6ul development board porting EMMC startup process of mainline u-boot
想要实现在时序场景下“远超”通用数据库,需要做到哪几点?
【信号处理】数字信号处理Matlab设计附GUI界面和报告
kubernetes 二进制安装(v1.20.15)(六)部署WorkNode节点
kubernetes 二进制安装(v1.20.16)(五)验证 master 部署
Mctalk's entrepreneurial voice - erudition and discernment: be interested in socializing, and provide a "small and beautiful" space for old friends before and after retirement
[ArcGIS]城市关联度分析