svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.jdbc / src / main / java / org / gvsig / fmap / dal / store / jdbc2 / spi / DataTransactionConnection.java @ 45650
History | View | Annotate | Download (2.28 KB)
1 |
/*
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2020 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 |
*
|
19 |
* For any additional information, do not hesitate to contact us
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
21 |
*/
|
22 |
|
23 |
package org.gvsig.fmap.dal.store.jdbc2.spi; |
24 |
|
25 |
import java.sql.Connection; |
26 |
import java.sql.SQLException; |
27 |
import org.gvsig.fmap.dal.exception.DataException; |
28 |
import org.gvsig.fmap.dal.spi.DataTransactionServices; |
29 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
30 |
|
31 |
/**
|
32 |
*
|
33 |
* @author gvSIG Team
|
34 |
*/
|
35 |
public class DataTransactionConnection implements DataTransactionServices.ConnectionService<Connection> { |
36 |
|
37 |
private final String id; |
38 |
private final Connection connection; |
39 |
|
40 |
public DataTransactionConnection(String id, Connection connection) { |
41 |
this.id = id;
|
42 |
this.connection = connection;
|
43 |
} |
44 |
|
45 |
@Override
|
46 |
public String getId() { |
47 |
return this.id; |
48 |
} |
49 |
|
50 |
@Override
|
51 |
public void begin() throws DataException { |
52 |
try {
|
53 |
this.connection.setAutoCommit(false); |
54 |
} catch (SQLException ex) { |
55 |
throw new JDBCSQLException(ex); |
56 |
} |
57 |
} |
58 |
|
59 |
@Override
|
60 |
public void commit() throws DataException { |
61 |
try {
|
62 |
this.connection.commit();
|
63 |
} catch (SQLException ex) { |
64 |
throw new JDBCSQLException(ex); |
65 |
} |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public void rollback() throws DataException { |
70 |
try {
|
71 |
this.connection.rollback();
|
72 |
} catch (SQLException ex) { |
73 |
throw new JDBCSQLException(ex); |
74 |
} |
75 |
} |
76 |
|
77 |
@Override
|
78 |
public Connection get() { |
79 |
return this.connection; |
80 |
} |
81 |
|
82 |
} |