Line 1... |
Line 1... |
1 |
/*
|
1 |
/*
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
3 |
*
|
3 |
*
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
4 |
* Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
|
5 |
*
|
5 |
*
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
9 |
* language governing permissions and limitations under the License.
|
9 |
* language governing permissions and limitations under the License.
|
Line 20... |
Line 20... |
20 |
import org.openconcerto.sql.model.SQLDataSource;
|
20 |
import org.openconcerto.sql.model.SQLDataSource;
|
21 |
import org.openconcerto.sql.model.SQLRequestLog;
|
21 |
import org.openconcerto.sql.model.SQLRequestLog;
|
22 |
import org.openconcerto.sql.model.SQLResultSet;
|
22 |
import org.openconcerto.sql.model.SQLResultSet;
|
23 |
import org.openconcerto.sql.model.SQLSystem;
|
23 |
import org.openconcerto.sql.model.SQLSystem;
|
24 |
import org.openconcerto.utils.RTInterruptedException;
|
24 |
import org.openconcerto.utils.RTInterruptedException;
|
- |
|
25 |
import org.openconcerto.utils.cc.ITransformerExn;
|
25 |
|
26 |
|
26 |
import java.sql.Connection;
|
27 |
import java.sql.Connection;
|
27 |
import java.sql.ResultSet;
|
28 |
import java.sql.ResultSet;
|
28 |
import java.sql.SQLException;
|
29 |
import java.sql.SQLException;
|
29 |
import java.sql.Savepoint;
|
30 |
import java.sql.Savepoint;
|
Line 97... |
Line 98... |
97 |
*/
|
98 |
*/
|
98 |
public static <T, X extends Exception> T executeAtomic(final SQLDataSource ds, final ConnectionHandlerNoSetup<T, X> h) throws SQLException, X {
|
99 |
public static <T, X extends Exception> T executeAtomic(final SQLDataSource ds, final ConnectionHandlerNoSetup<T, X> h) throws SQLException, X {
|
99 |
return executeAtomic(ds, h, false);
|
100 |
return executeAtomic(ds, h, false);
|
100 |
}
|
101 |
}
|
101 |
|
102 |
|
- |
|
103 |
public static final <T, X extends Exception> T executeAtomic(final SQLDataSource ds, final ITransformerExn<? super SQLDataSource, T, X> run) throws SQLException, X {
|
- |
|
104 |
return executeAtomic(ds, new ConnectionHandlerNoSetup<T, X>() {
|
- |
|
105 |
@Override
|
- |
|
106 |
public T handle(SQLDataSource ds) throws X {
|
- |
|
107 |
return run.transformChecked(ds);
|
- |
|
108 |
}
|
- |
|
109 |
});
|
- |
|
110 |
}
|
- |
|
111 |
|
102 |
/**
|
112 |
/**
|
103 |
* Execute <code>h</code> in a transaction. Only the outer most call to
|
113 |
* Execute <code>h</code> in a transaction. Only the outer most call to
|
104 |
* <code>executeAtomic()</code> commit or roll back a transaction, for recursive calls if
|
114 |
* <code>executeAtomic()</code> commit or roll back a transaction, for recursive calls if
|
105 |
* <code>continueTx</code> is <code>true</code> then nothing happens, else a save point is
|
115 |
* <code>continueTx</code> is <code>true</code> then nothing happens, else a save point is
|
106 |
* created and rolled back if an exception occurs (allowing the caller to catch the exception
|
116 |
* created and rolled back if an exception occurs (allowing the caller to catch the exception
|