小编Ash*_*win的帖子

尝试插入Oracle DB时Java线程永远保持锁定

我们有一个Java应用程序,可定期将行插入Oracle DB中。这是一个多线程应用程序。禁止一个的所有线程都会定期卡住。我们正在考虑升级Oracle JDBC驱动程序,但我感觉它可能会再次出现。只是想获取一些有关我们的代码或其他错误的信息。我既有stacktrace,也有下面的代码。我们在线程信息中看到定期锁定。请向我们提供一些有关我可能会出错的信息。

- - 码 - -

LogEventBatchPreparedStatementUpdater statementUpdater = new LogEventBatchPreparedStatementUpdater(logEvents);

//        _jdbcTemplate.batchUpdate(INSERT_SQL, statementUpdater);
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        try
        {
            connection = _dataSource.getConnection();
            connection.setAutoCommit(false);
            preparedStatement = connection.prepareStatement(INSERT_SQL);
            for (int i = 0; i < statementUpdater.getBatchSize(); i++)
            {
                statementUpdater.setValues(preparedStatement, i);
                preparedStatement.addBatch();
            }
            preparedStatement.executeBatch();
            connection.commit();
        }
        catch (SQLException e)
        {
            _Log.error("Error inserting log line batch",e );
        }
        finally
        {
            try
            {
                preparedStatement.close();
                connection.close();
            }
            catch (SQLException e)
            {
                _Log.error("Error inserting log line batch",e );
            }
        } …
Run Code Online (Sandbox Code Playgroud)

oracle multithreading deadlock jdbc

2
推荐指数
1
解决办法
2013
查看次数

标签 统计

deadlock ×1

jdbc ×1

multithreading ×1

oracle ×1