|
33 | 33 | package org.exist.xquery.modules.sql;
|
34 | 34 |
|
35 | 35 | import com.zaxxer.hikari.HikariDataSource;
|
| 36 | +import com.zaxxer.hikari.HikariPoolMXBean; |
36 | 37 | import org.apache.logging.log4j.LogManager;
|
37 | 38 | import org.apache.logging.log4j.Logger;
|
38 | 39 |
|
@@ -173,18 +174,27 @@ private Connection getConnectionFromPool(final Sequence[] args) throws XPathExce
|
173 | 174 | throw new XPathException(this, "There is no configured connection pool named: " + poolName);
|
174 | 175 | }
|
175 | 176 |
|
| 177 | + Connection connection = null; |
176 | 178 | try {
|
177 | 179 | if (args.length == 3) {
|
178 | 180 | final String username = args[1].getStringValue();
|
179 | 181 | final String password = args[2].getStringValue();
|
180 |
| - return pool.getConnection(username, password); |
| 182 | + connection = pool.getConnection(username, password); |
181 | 183 | } else {
|
182 |
| - return pool.getConnection(); |
| 184 | + connection = pool.getConnection(); |
183 | 185 | }
|
184 | 186 | } catch (final SQLException sqle) {
|
185 | 187 | LOGGER.error("sql:get-connection-from-pool() Cannot retrieve connection from pool: " + poolName, sqle);
|
186 | 188 | throw new XPathException(this, "sql:get-connection-from-pool() Cannot retrieve connection from pool: " + poolName, sqle);
|
187 | 189 | }
|
| 190 | + |
| 191 | + HikariPoolMXBean poolBean = pool.getHikariPoolMXBean(); |
| 192 | + |
| 193 | + if (poolBean.getThreadsAwaitingConnection() > 0) { |
| 194 | + LOGGER.info("getConnectionFromPool("+poolName+"), "+poolBean.getActiveConnections()+" active, "+poolBean.getIdleConnections()+" available, "+poolBean.getThreadsAwaitingConnection()+" waiting, "+poolBean.getTotalConnections()+" total connections."); |
| 195 | + } |
| 196 | + |
| 197 | + return connection; |
188 | 198 | }
|
189 | 199 |
|
190 | 200 | private static FunctionSignature[] functionSignatures(final String name, final String description, final FunctionReturnSequenceType returnType, final FunctionParameterSequenceType[][] variableParamTypes) {
|
|
0 commit comments