-
胡子哥哥
[i]stmt_Select.close(); [/i]
stmt_Select=con.createStatement();
[i] stmt_Update.close();[/i]
stmt_Update=con.createStatement();不要在循环里面频繁的close, 全部放在rs.close()之前参考如下stmt_Select.close();stmt_Update.close();rs.close();
-
慕妹3146593
PreparedStatement[quote] PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEESSET SALARY = ? WHERE ID = ?");pstmt.setBigDecimal(1, 153833.00)pstmt.setInt(2, 110592)[/quote]
-
大话西游666
建议写个存储过程处理,你的业务也不算复杂。与数据库交互必然会耗费很多时间的。
-
米脂
建议你使用Updatable statement,给你一段我以前写过的代码吧,这段代码用来处理14万条记录,具体时间记不太清了,不过效率还是挺高的:[code="java"]String sql = "select ccrq,dt_factory_date from ajdq";Connection con = DbUtil._CONNECTION;//获得数据库连接Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);ResultSet rs = st.executeQuery(sql);int i=0;while(rs.next()){String date = rs.getString(1);Date d = DateUtil.parse(date);if(d!=null){rs.updateTimestamp(2, new Timestamp(d.getTime()));rs.updateRow();i++;System.out.print(".");if(i%100==0){System.out.println(i);con.commit();}}}rs.close();st.close();System.out.println();System.out.println(i);con.commit();con.close();[/code]