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 23... |
Line 23... |
23 |
import org.openconcerto.utils.RTInterruptedException;
|
23 |
import org.openconcerto.utils.RTInterruptedException;
|
24 |
import org.openconcerto.utils.ThreadFactory;
|
24 |
import org.openconcerto.utils.ThreadFactory;
|
25 |
import org.openconcerto.utils.Tuple2;
|
25 |
import org.openconcerto.utils.Tuple2;
|
26 |
import org.openconcerto.utils.cache.CacheResult;
|
26 |
import org.openconcerto.utils.cache.CacheResult;
|
27 |
import org.openconcerto.utils.cache.ICacheSupport;
|
27 |
import org.openconcerto.utils.cache.ICacheSupport;
|
- |
|
28 |
import org.openconcerto.utils.cc.ITransformerExn;
|
28 |
|
29 |
|
29 |
import java.beans.PropertyChangeEvent;
|
30 |
import java.beans.PropertyChangeEvent;
|
30 |
import java.beans.PropertyChangeListener;
|
31 |
import java.beans.PropertyChangeListener;
|
31 |
import java.sql.Connection;
|
32 |
import java.sql.Connection;
|
32 |
import java.sql.ResultSet;
|
33 |
import java.sql.ResultSet;
|
Line 283... |
Line 284... |
283 |
}
|
284 |
}
|
284 |
}
|
285 |
}
|
285 |
|
286 |
|
286 |
// if TCP isn't used or is used to connect to localhost, TCP should be quite robust
|
287 |
// if TCP isn't used or is used to connect to localhost, TCP should be quite robust
|
287 |
private final Level getLogLevelForIgnoredTCPParam() {
|
288 |
private final Level getLogLevelForIgnoredTCPParam() {
|
288 |
return SQLSyntax.get(this.sysRoot).isServerLocalhost(this.sysRoot.getServer()) ? Level.CONFIG : Level.WARNING;
|
289 |
return this.sysRoot.getServer().isLocalhost() ? Level.CONFIG : Level.WARNING;
|
289 |
}
|
290 |
}
|
290 |
|
291 |
|
291 |
public final void setTCPKeepAlive(final boolean b) {
|
292 |
public final void setTCPKeepAlive(final boolean b) {
|
292 |
if (this.getSystem() == SQLSystem.POSTGRESQL || this.getSystem() == SQLSystem.MYSQL) {
|
293 |
if (this.getSystem() == SQLSystem.POSTGRESQL || this.getSystem() == SQLSystem.MYSQL) {
|
293 |
this.addConnectionProperty("tcpKeepAlive", String.valueOf(b));
|
294 |
this.addConnectionProperty("tcpKeepAlive", String.valueOf(b));
|
Line 834... |
Line 835... |
834 |
|
835 |
|
835 |
private final HandlersStack getHandlersStack() {
|
836 |
private final HandlersStack getHandlersStack() {
|
836 |
return this.handlers.get(Thread.currentThread());
|
837 |
return this.handlers.get(Thread.currentThread());
|
837 |
}
|
838 |
}
|
838 |
|
839 |
|
- |
|
840 |
public final <T, X extends Exception> T useConnection(final ITransformerExn<? super SQLDataSource, T, X> run) throws SQLException, X {
|
- |
|
841 |
return this.useConnection(new ConnectionHandlerNoSetup<T, X>() {
|
- |
|
842 |
@Override
|
- |
|
843 |
public T handle(SQLDataSource ds) throws X {
|
- |
|
844 |
return run.transformChecked(ds);
|
- |
|
845 |
}
|
- |
|
846 |
});
|
- |
|
847 |
}
|
- |
|
848 |
|
839 |
/**
|
849 |
/**
|
840 |
* Use a single connection to execute <code>handler</code>.
|
850 |
* Use a single connection to execute <code>handler</code>.
|
841 |
*
|
851 |
*
|
842 |
* @param <T> type of return.
|
852 |
* @param <T> type of return.
|
843 |
* @param <X> type of exception.
|
853 |
* @param <X> type of exception.
|