私は奇妙な問題に悩まされています.MySQL 5.1データベースにSELECTクエリを実行し、UPDATEクエリをコミットし、その後SELECTクエリを再度実行できません(Javaは列が見つからないと文句を言います)。
ここに私のコードがあります:
//SELECT
dbhIrmdb.setAutoCommit(false);
PreparedStatement preparedSelect=null;
preparedSelect=dbhIrmdb.prepareStatement(query);
ResultSet rowSet=preparedSelect.executeQuery();
dbhIrmdb.commit();
while (rowSet.next()) {
computer=new ComputerInfo();
computer.setIndex(index); index++;
computer.setComputers_id(rowSet.getString("computers_id"));
....
}
dbhIrmdb.setAutoCommit(true);
//アップデート
PreparedStatement commonUpdate=null;
try {
String queryUpdate="UPDATE computers SET name=?, serial=?, inv_number=?, comments=?, rack_unit=?, box_unit=?, ram=? WHERE ID="
+currentComp.getComputers_id();
dbhIrmdb.setAutoCommit(false);
commonUpdate=dbhIrmdb.prepareStatement(queryUpdate);
commonUpdate.setString(1, currentComp.getComputers_name());
...
commonUpdate.executeUpdate();
dbhIrmdb.commit();
} catch (SQLException ex) {
ex.printStackTrace();
try {
System.err.print("Transaction is being rolled back");
dbhIrmdb.rollback();
} catch(SQLException excep) {
excep.printStackTrace();
}
}
finally {
if (commonUpdate != null) {
commonUpdate.close();
}
dbhIrmdb.setAutoCommit(true);
}
サイトを調べてみましたが、そのような事例は見つかりませんでした。
助けやアドバイスをいただければ幸いです。