我们有一个 Java 工作流应用程序,它使用 Oracle 数据库来跟踪其步骤以及与其他服务的交互。在工作流运行期间,会执行多次插入/更新/选择,有时选择不会返回更新的数据,即使插入/更新提交在成功完成之前运行也是如此。工作流程出错后(由于数据错误),如果我们返回并通过第三方应用程序检查数据库,则会显示新的/更新的数据。我们的提交完成和可见之间似乎存在滞后。这种情况发生在所有工作流运行的大约 2% 中,并且在数据库使用量很大时会增加。
我们的数据库支持团队建议将参数 max-commit-propagation-delay 更改为 0,因为它默认为 700。这似乎是一个可能的解决方案,但最终并没有解决我们的问题。
该应用程序在WebSphere 上运行,并且Oracle 数据库配置为JDBC 数据源。我们使用的是 Oracle 10.1g。该应用程序是用 Java 1.5 编写的。
任何帮助,将不胜感激。
编辑:示例代码
DataSource ds; // spring configured
String sql = "INSERT INTO " + currentTable + " (" + stepId + ',' + stepEntryId + ", " + stepStepId + ", " + stepActionId + ", " + stepOwner + ", " + stepStartDate + ", " + stepDueDate + ", " + stepFinishDate + ", " + stepStatus + ", " + stepCaller + " ) VALUES (?, ?, ?, null, ?, ?, ?, null, ?, null)";
Connection conn = ds.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql);
// set values
stmt.executeUpdate();
// close connections
// later on in the code...
Connection conn = ds.getConnection();
PreparedStatement stmt = null;
ResultSet rset = null;
String sql = "SELECT " + stepId + ", " + stepStepId + ", " + stepActionId + ", " + stepOwner + ", " + stepStartDate + ", " + stepDueDate + ", " + stepFinishDate + ", " + stepStatus + ", " + stepCaller + " FROM " + currentTable + " WHERE " + stepEntryId + " = ?";
stmt = conn.prepareStatement(sql);
stmt.setLong(1, entryId);
rset = stmt.executeQuery();
//close connections