KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > db > dao > jdbc > SqlMap2DaoTransaction


1 /*
2  * Copyright 2004 Clinton Begin
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package com.ibatis.db.dao.jdbc;
17
18 import com.ibatis.db.dao.DaoException;
19 import com.ibatis.db.dao.DaoTransaction;
20 import com.ibatis.sqlmap.client.SqlMapClient;
21
22 import java.sql.SQLException JavaDoc;
23
24 public class SqlMap2DaoTransaction implements DaoTransaction {
25
26
27   private SqlMapClient client;
28
29   public SqlMap2DaoTransaction(SqlMapClient sqlMap) {
30     this.client = sqlMap;
31   }
32
33   public void commit() throws DaoException {
34     try {
35       client.commitTransaction();
36       client.endTransaction();
37     } catch (SQLException JavaDoc e) {
38       throw new DaoException("Error committing transaction. Cause: " + e, e);
39     }
40   }
41
42   public void rollback() throws DaoException {
43     try {
44       client.endTransaction();
45     } catch (SQLException JavaDoc e) {
46       throw new DaoException("Error rolling back transaction. Cause: " + e, e);
47     }
48   }
49
50   public void release() throws DaoException {
51     // No implementation required.
52
}
53
54   public SqlMapClient getSqlMapClient() {
55     return client;
56   }
57
58 }
59
Popular Tags