关于No ManagedConnections available within configured blocking timeout异常的解决
最近由于系统和业务重构需要,需要把线上1亿数据迁移到新库,由于业务变更,新表老表结构有变化,没法直接用dba dump的方式,需要自己写转换程序迁移。今天在调试的时候,碰到一个蛋疼的问题,就是一开始查询数据都正常,但是查询几条后日志就会报超时错误,具体日志如下:
1 try{ 2 conn = sourceDs.getConnection(); 3 ps = conn.prepareStatement(selectTcBizOrder); 4 rs = ps.executeQuery(); 5 if(rs.next()){ 6 result.put("auction_id", rs.getLong("auction_id")); 7 result.put("logistics_status", rs.getInt("logistics_status")); 8 result.put("attributes", rs.getString("attributes")); 9 return result;10 }else{11 return null;12 }13 }catch(SQLException e){14 LogFactory.getTaskLog().error("[select tc_biz_order SQLException], bizOrderId="+bizOrderId, e);15 return null;16 }catch(Exception e){17 LogFactory.getTaskLog().error("[select tc_biz_order other Exception], bizOrderId="+bizOrderId, e);18 return null;19 }finally{20 if(rs != null){21 try{22 rs.close();23 }catch(SQLException e){24 LogFactory.getTaskLog().error("[close ResultSet SQLException], bizOrderId="+bizOrderId, e);25 }26 }27 28 if(ps != null){29 try {30 ps.close();31 } catch (SQLException e) {32 LogFactory.getTaskLog().error("[close PreparedStatement SQLException], bizOrderId="+bizOrderId, e);33 }34 }35 36 if(conn != null){37 try{38 conn.close();39 }catch(SQLException e){40 LogFactory.getTaskLog().error("[close Connection SQLException], bizOrderId="+bizOrderId, e);41 }42 }43 }
?