Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2016-10-07 11:06:29 -0400
committerjmisinco2016-10-12 15:43:44 -0400
commit640a4a50b1195e94c947fbdde5b0a94d64652eff (patch)
tree8d6bb3d333750e8a1f31723b11884986622a4041
parentef287c31a02c10a295528394a978f82a196fe7fe (diff)
downloadorg.eclipse.osee-640a4a50b1195e94c947fbdde5b0a94d64652eff.tar.gz
org.eclipse.osee-640a4a50b1195e94c947fbdde5b0a94d64652eff.tar.xz
org.eclipse.osee-640a4a50b1195e94c947fbdde5b0a94d64652eff.zip
bug[ats_ATS317221]: JDBC Pool error after running OSEE Client integration test twice
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcClient.java4
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcConnection.java2
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcDbType.java2
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcPoolConfig.java2
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcClientImpl.java24
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcConnectionImpl.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeUnusedBackingDataAndTransactions.java61
7 files changed, 54 insertions, 53 deletions
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcClient.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcClient.java
index d454bec2ce4..1601646e45b 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcClient.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcClient.java
@@ -31,8 +31,12 @@ public interface JdbcClient {
int runQuery(Consumer<JdbcStatement> consumer, String query, Object... data);
+ int runQuery(JdbcConnection connection, Consumer<JdbcStatement> consumer, String query, Object... data);
+
int runQuery(Consumer<JdbcStatement> consumer, int fetchSize, String query, Object... data);
+ int runQuery(JdbcConnection connection, Consumer<JdbcStatement> consumer, int fetchSize, String query, Object... data);
+
int runQueryWithLimit(Consumer<JdbcStatement> consumer, int limit, String query, Object... data);
<R> R fetch(R defaultValue, String query, Object... data);
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcConnection.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcConnection.java
index 54598efe57f..e948a460304 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcConnection.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcConnection.java
@@ -22,8 +22,6 @@ public interface JdbcConnection extends AutoCloseable {
boolean isClosed();
- boolean isStale();
-
DatabaseMetaData getMetaData();
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcDbType.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcDbType.java
index 428549a586e..7fd17171221 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcDbType.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcDbType.java
@@ -96,6 +96,8 @@ public class JdbcDbType extends BaseId {
public String getValidationSql() {
if (matches(oracle, h2)) {
return "select 1 from dual";
+ } else if (matches(hsql)) {
+ return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
}
return "select 1";
}
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcPoolConfig.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcPoolConfig.java
index 7591c8fe80b..0d3bf23643d 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcPoolConfig.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/JdbcPoolConfig.java
@@ -480,7 +480,7 @@ public class JdbcPoolConfig {
setPoolMaxActiveConnections(getIntObj(props, "maxActive", DEFAULT_JDBC_POOL__MAX_ACTIVE_CONNECTIONS));
setPoolMaxActivePreparedStatements( getIntObj(props, "maxActivePreparedStatements", DEFAULT_JDBC_POOL__MAX_ACTIVE_PREPARED_STATEMENTS));
setPoolMaxIdleConnections(getIntObj(props, "maxIdle", DEFAULT_JDBC_POOL__MAX_IDLE_CONNECTIONS));
- setPoolMaxIdlePreparedStatements(getIntObj(props, "maxIdlePreparedStatements", DEFAULT_JDBC_POOL__MIN_IDLE_PREPARED_STATEMENTS));
+ setPoolMaxIdlePreparedStatements(getIntObj(props, "maxIdlePreparedStatements", DEFAULT_JDBC_POOL__MAX_IDLE_PREPARED_STATEMENTS));
setPoolMaxTotalPreparedStatements(getIntObj(props, "maxTotalPreparedStatements", DEFAULT_JDBC_POOL__MAX_TOTAL_PREPARED_STATEMENTS));
setPoolMaxWaitForConnection(getLongObj(props, "maxWait", DEFAULT_JDBC_POOL__MAX_WAIT_CONNECTIONS));
setPoolMaxWaitPreparedStatements( getLongObj(props, "maxWaitPreparedStatements", DEFAULT_JDBC_POOL__MAX_WAIT_PREPARED_STATEMENTS));
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcClientImpl.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcClientImpl.java
index f846113d5f7..da29a08d1c3 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcClientImpl.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcClientImpl.java
@@ -204,11 +204,8 @@ public final class JdbcClientImpl implements JdbcClient {
@Override
public int runPreparedUpdate(String query, Object... data) throws JdbcException {
- JdbcConnection connection = getConnection();
- try {
+ try (JdbcConnection connection = getConnection()) {
return runPreparedUpdate(connection, query, data);
- } finally {
- connection.close();
}
}
@@ -219,8 +216,7 @@ public final class JdbcClientImpl implements JdbcClient {
throw newJdbcException("defaultValue cannot be null");
}
String sql = getDbType().getFunctionCallSql(function);
- JdbcConnectionImpl connection = getConnection();
- try {
+ try (JdbcConnectionImpl connection = getConnection()) {
CallableStatement stmt = null;
try {
stmt = connection.prepareCall(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
@@ -305,8 +301,6 @@ public final class JdbcClientImpl implements JdbcClient {
} finally {
JdbcUtil.close(stmt);
}
- } finally {
- connection.close();
}
}
@@ -316,14 +310,26 @@ public final class JdbcClientImpl implements JdbcClient {
}
@Override
+ public int runQuery(JdbcConnection connection, Consumer<JdbcStatement> consumer, String query, Object... data) {
+ return runQuery(connection, consumer, 0, query, data);
+ }
+
+ @Override
public int runQuery(Consumer<JdbcStatement> consumer, String query, Object... data) {
return runQuery(consumer, 0, query, data);
}
@Override
public int runQuery(Consumer<JdbcStatement> consumer, int fetchSize, String query, Object... data) {
+ try (JdbcConnection conn = getConnection()) {
+ return runQuery(conn, consumer, fetchSize, query, data);
+ }
+ }
+
+ @Override
+ public int runQuery(JdbcConnection connection, Consumer<JdbcStatement> consumer, int fetchSize, String query, Object... data) {
int rowCount = 0;
- try (JdbcStatement stmt = getStatement()) {
+ try (JdbcStatement stmt = getStatement(connection)) {
stmt.runPreparedQuery(fetchSize, query, data);
while (stmt.next()) {
consumer.accept(stmt);
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcConnectionImpl.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcConnectionImpl.java
index 4bee848d7b9..3ac2932da83 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcConnectionImpl.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/JdbcConnectionImpl.java
@@ -25,7 +25,6 @@ import org.eclipse.osee.jdbc.JdbcException;
*/
public class JdbcConnectionImpl implements JdbcConnection {
- private static final int STALE_CONNECTION_TIMEOUT = 60000;
private final Connection conn;
public JdbcConnectionImpl(Connection conn) {
@@ -34,17 +33,6 @@ public class JdbcConnectionImpl implements JdbcConnection {
}
@Override
- public boolean isStale() {
- boolean result = true;
- try {
- result = !conn.isValid(STALE_CONNECTION_TIMEOUT);
- } catch (SQLException ex) {
- // do nothing
- }
- return result;
- }
-
- @Override
public void close() {
destroy();
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeUnusedBackingDataAndTransactions.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeUnusedBackingDataAndTransactions.java
index aeb97efa88b..7c5f57f2502 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeUnusedBackingDataAndTransactions.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/PurgeUnusedBackingDataAndTransactions.java
@@ -14,6 +14,7 @@ import static org.eclipse.osee.jdbc.JdbcConstants.JDBC__MAX_FETCH_SIZE;
import java.util.function.BiConsumer;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.jdbc.JdbcClient;
+import org.eclipse.osee.jdbc.JdbcConnection;
import org.eclipse.osee.jdbc.JdbcStatement;
import org.eclipse.osee.jdbc.OseePreparedStatement;
@@ -59,40 +60,40 @@ public class PurgeUnusedBackingDataAndTransactions {
this.jdbcClient = jdbcClient;
}
- private int purgeNotAddressedGammas(String tableName) throws OseeCoreException {
+ private int purgeNotAddressedGammas(JdbcConnection connection, String tableName) throws OseeCoreException {
String selectSql = String.format(NOT_ADDRESSESED_GAMMAS, tableName);
- return purgeGammas(selectSql, tableName);
+ return purgeGammas(connection, selectSql, tableName);
}
- private int purgeAddressedButNonexistentGammas(String tableName) throws OseeCoreException {
- return purgeData(String.format(NONEXISTENT_GAMMAS, tableName), String.format(DELETE_GAMMAS_BY_BRANCH, tableName),
- this::addBranchGamma);
+ private int purgeAddressedButNonexistentGammas(JdbcConnection connection, String tableName) throws OseeCoreException {
+ return purgeData(connection, String.format(NONEXISTENT_GAMMAS, tableName),
+ String.format(DELETE_GAMMAS_BY_BRANCH, tableName), this::addBranchGamma);
}
- private int purgeEmptyTransactions() throws OseeCoreException {
- return purgeData(EMPTY_TRANSACTIONS, DELETE_EMPTY_TRANSACTIONS, this::addTx);
+ private int purgeEmptyTransactions(JdbcConnection connection) throws OseeCoreException {
+ return purgeData(connection, EMPTY_TRANSACTIONS, DELETE_EMPTY_TRANSACTIONS, this::addTx);
}
- private int deleteObsoleteTags() {
- return purgeGammas(OBSOLETE_TAGS, "osee_search_tags");
+ private int deleteObsoleteTags(JdbcConnection connection) {
+ return purgeGammas(connection, OBSOLETE_TAGS, "osee_search_tags");
}
- private int purgeInvalidArtfactReferences(String table, String artColumn) {
+ private int purgeInvalidArtfactReferences(JdbcConnection connection, String table, String artColumn) {
String selectSql = String.format(GET_INVALID_ART_REFERENCES, table, artColumn);
- return purgeGammas(selectSql, table);
+ return purgeGammas(connection, selectSql, table);
}
- private int purgeInvalidArtfactReferencesAcl() {
- return purgeData(GET_INVALID_ART_REFERENCES_ACL, DELETE_ACL, this::addArt);
+ private int purgeInvalidArtfactReferencesAcl(JdbcConnection connection) {
+ return purgeData(connection, GET_INVALID_ART_REFERENCES_ACL, DELETE_ACL, this::addArt);
}
- private int purgeGammas(String selectSql, String table) {
- return purgeData(selectSql, String.format(DELETE_GAMMAS, table), this::addGamma);
+ private int purgeGammas(JdbcConnection connection, String selectSql, String table) {
+ return purgeData(connection, selectSql, String.format(DELETE_GAMMAS, table), this::addGamma);
}
- private int purgeData(String selectSql, String purgeSQL, BiConsumer<OseePreparedStatement, JdbcStatement> consumer) {
- OseePreparedStatement purgeStmt = jdbcClient.getBatchStatement(purgeSQL);
- jdbcClient.runQuery(stmt -> consumer.accept(purgeStmt, stmt), JDBC__MAX_FETCH_SIZE, selectSql);
+ private int purgeData(JdbcConnection connection, String selectSql, String purgeSQL, BiConsumer<OseePreparedStatement, JdbcStatement> consumer) {
+ OseePreparedStatement purgeStmt = jdbcClient.getBatchStatement(connection, purgeSQL);
+ jdbcClient.runQuery(connection, stmt -> consumer.accept(purgeStmt, stmt), JDBC__MAX_FETCH_SIZE, selectSql);
return purgeStmt.execute();
}
@@ -115,17 +116,19 @@ public class PurgeUnusedBackingDataAndTransactions {
public int[] purge() {
int i = 0;
int[] counts = new int[11];
- counts[i++] = purgeNotAddressedGammas("osee_artifact");
- counts[i++] = purgeNotAddressedGammas("osee_attribute");
- counts[i++] = purgeNotAddressedGammas("osee_relation_link");
- counts[i++] = purgeInvalidArtfactReferences("osee_relation_link", "a_art_id");
- counts[i++] = purgeInvalidArtfactReferences("osee_relation_link", "b_art_id");
- counts[i++] = purgeInvalidArtfactReferences("osee_attribute", "art_id");
- counts[i++] = purgeInvalidArtfactReferencesAcl();
- counts[i++] = deleteObsoleteTags();
- counts[i++] = purgeAddressedButNonexistentGammas("osee_txs");
- counts[i++] = purgeAddressedButNonexistentGammas("osee_txs_archived");
- counts[i++] = purgeEmptyTransactions();
+ try (JdbcConnection connection = jdbcClient.getConnection()) {
+ counts[i++] = purgeNotAddressedGammas(connection, "osee_artifact");
+ counts[i++] = purgeNotAddressedGammas(connection, "osee_attribute");
+ counts[i++] = purgeNotAddressedGammas(connection, "osee_relation_link");
+ counts[i++] = purgeInvalidArtfactReferences(connection, "osee_relation_link", "a_art_id");
+ counts[i++] = purgeInvalidArtfactReferences(connection, "osee_relation_link", "b_art_id");
+ counts[i++] = purgeInvalidArtfactReferences(connection, "osee_attribute", "art_id");
+ counts[i++] = purgeInvalidArtfactReferencesAcl(connection);
+ counts[i++] = deleteObsoleteTags(connection);
+ counts[i++] = purgeAddressedButNonexistentGammas(connection, "osee_txs");
+ counts[i++] = purgeAddressedButNonexistentGammas(connection, "osee_txs_archived");
+ counts[i++] = purgeEmptyTransactions(connection);
+ }
return counts;
}
} \ No newline at end of file

Back to the top