0

iBATISを使用して PostgreSQL データベースにデータを挿入しても機能せず、例外も発生しません。これから抜け出すのを手伝ってください。

このコードは時々機能しますが、毎回ではありません。コードは適切に実行され、例外やエラーは発生していません。

以下のコードは、データをデータベースに挿入するために使用されます。

public void insert() {
    map.put("customer", customer);
    map.put("created_by", created_by);
    map.put("created_date", created_date);
    map.put("modified_by", modified_by);
    map.put("last_modified", last_modified);
    map.put("total_cost", total_cost);
    map.put("tax", tax);
    map.put("bill_number", bill_number);
    map.put("date_of_sale", date_of_sale);
    try {
        SqlMapClient mapClient=GetDBConnection.sqlMapClientForLedger;
        mapClient.insert("insertTaxDiscountMemosbyanil", map);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
4

1 に答える 1

1

トランザクションを追加してみてください。

try {
   mapClient.startTransaction()
   mapClient.insert("insertTaxDiscountMemosbyanil", map);
   mapClient.commitTransaction();
 } 
finally {
   mapClient.endTransaction();
}
于 2013-02-18T08:55:08.813 に答える