代码是
try{
sql = "select * from account";
rs = st.executeQuery(sql);
while (rs.next()) {
//取出三个字段的值,然后使用java,aes算法使值变化
updateSql = "update account set account='" + test2 ...
st2.executeUpdate(updateSql);
} catch (Exception e) {
e.printStackTrace();
} finally { // bw.close();
// bw2.close();
st2.close();
st.close();
conn.close();
}
发现,更新时一小时才1000条,请问如果提高速度,那个aes算法,不是性能的瓶颈。谢谢。

解决方案 »

  1.   

    先生成update语句,然后用batch更新
      

  2.   

    bath,連接池頻繁開關數據庫連接也是很耗費資源的
      

  3.   

    我在想一个办法,是account表有1000w行数据,我想是不是要分成50w跑一个。这样可以提供20倍性能。
      

  4.   

    楼主用可更新结果集试过没有?Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);ResultSet res = stmt.executeQuery("select * from account");res.updateString("account", 新值); //假设是字符类型res.updateRow();等等。
      

  5.   

    可以批处理的。jdbc里面有个batchUpdate,可以批处理的。很快我一次修改两万多条数据,两秒就可以搞定住楼主好运!下面附代码:public void excuteSql_batchUpdate(String qsh,String zzh,String updateZt) {
    final List mphs = WebUtils.getMphs(qsh, zzh);
    if (mphs != null && mphs.size()>0) {
    this.getJdbcTemplate().getJdbcOperations().batchUpdate(updateZt, new BatchPreparedStatementSetter() {
                    public void setValues(PreparedStatement ps, int i) throws SQLException {
                        ps.setString(1, String.valueOf(mphs.get(i)));
                    }
                    public int getBatchSize() {
                        return mphs.size();
                    }
                } );
    }
    }