以上是jconsole看到的信息,程序是去oracle更新数据,之后执行到executeUpdate()卡住,没有任何异常,如果不手动停止可以卡一天,更新的代码没有任何问题,因为在我电脑上怎么跑都不会有问题,以上卡住问题出现在用户现场,而且偶尔是可以更新的,只是大部分都是会卡住,求大神解答
并发,死锁
可以请DBA帮忙看下是否有锁住的语句
有没有可能程序其他功能影响了jdbc更新?程序是导出数据,每导出一定数量,去oracle更新数目
public void close(Connection connection,PreparedStatement ps,ResultSet rs) throws Exception{
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (ps != null) {
try {
ps.close();
} catch (Exception e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} 我是楼主小号,被禁言了,,,我每次数据库操作都调用这个方法,(刚才又检查了遍),而且我写了只更新数据的方法,执行一万次,没有问题,在用户环境也没问题,但是程序整体运行就会卡在更新处,求解答
借楼,我执行到executeBatch就卡住了,为啥,求各位大佬帮忙看看
public static void updateCategory_ID() {
try {
int j=0;
con = DBConn.getConnection();
String sql = "select * from O8100_SPXX_201907_4 where category_id like '%//%' ";
String sql1 = "update O8100_SPXX_201907_4 set category_id =? where goods_id =?";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
con.setAutoCommit(false);
ps = con.prepareStatement(sql1);
while (rs.next()) {
String category_id = rs.getString("category_id");
String[] array = category_id.split(" ");
String category_id1 = "";
for (int i = 0; i < array.length; i++) {
Matcher matcher = Pattern.compile("(com/|item/)(\d+)").matcher(array[i]);
while (matcher.find()) {
category_id1 = matcher.group(2) + " " + category_id1;
}
}
ps.setString(1, category_id1);
ps.setString(2, rs.getString("goods_id"));
ps.addBatch();
System.out.println(category_id1);
j++;
if(j%1000==0)
{
con.setAutoCommit(false);
ps.executeBatch();
con.commit();
ps.clearBatch();
}
}
ps.executeBatch();
con.commit();// 执行完后,手动提交事务
con.setAutoCommit(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (con != null) {
con.close();
}
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}