Details
Description
Sent to me from Michael Beier
in some adapters (e.g mssql, sybase) lockTables is implemented as follows:
public void lockTable(Connection con, String table) throws SQLException
{
Statement statement = con.createStatement();
stmt.append("SELECT next_id FROM ")
.append(table)
.append(" FOR UPDATE");
}
Problem is that the column next_id does not exist in most tables.
Suggested is to replace this as follows:
Mssql:
{
Statement statement = con.createStatement();
StringBuffer stmt = new StringBuffer();
stmt.append("SELECT * FROM ")
.append(table)
.append(" WITH (TABLOCKX)");
statement.executeQuery(stmt.toString());
}
Oracle:
public void lockTable(Connection con, String table) throws SQLException
{
Statement statement = con.createStatement();
StringBuffer stmt = new StringBuffer();
stmt.append("SELECT * FROM ")
.append(table)
.append(" FOR UPDATE");
statement.executeQuery(stmt.toString());
}