Skip to content

Commit

Permalink
ARTEMIS-1757 Improve DB2 compatibility
Browse files Browse the repository at this point in the history
It includes:
- Fixed AUTO_INCREMENT not supported on DB2
- Added proper stop/teardown of driver
- Fixed recursive SQLException formatting
  • Loading branch information
franz1981 authored and clebertsuconic committed Mar 27, 2018
1 parent 5a39446 commit 8842ac3
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 4 deletions.
Expand Up @@ -95,6 +95,7 @@ public void stop() throws SQLException {
synchronized (connection) {
if (sqlProvider.closeConnectionOnShutdown()) {
try {
connection.setAutoCommit(true);
connection.close();
} catch (SQLException e) {
logger.error(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), e));
Expand Down
Expand Up @@ -82,7 +82,7 @@ public static StringBuilder appendSQLExceptionDetails(StringBuilder errorMessage
errorMessage.append(' ');
}
formatSqlException(errorMessage, nextEx);
nextEx = exception.getNextException();
nextEx = nextEx.getNextException();
level++;
}
while (nextEx != null);
Expand Down
3 changes: 3 additions & 0 deletions artemis-jdbc-store/src/main/resources/journal-sql.properties
Expand Up @@ -84,3 +84,6 @@ create-journal-table.oracle=CREATE TABLE %s(id NUMBER(19),recordType NUMBER(5),c
# 4 GiB
max-blob-size.oracle=4294967296
table-names-case.oracle=upper

# DB2 SQL statements
create-file-table.db2=CREATE TABLE %s (ID BIGINT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA BLOB, PRIMARY KEY(ID))
Expand Up @@ -511,6 +511,7 @@ public void destroyTables(List<String> tableNames) throws Exception {
connection.rollback();
}
}
connection.setAutoCommit(true);
} catch (Throwable e) {
e.printStackTrace();
} finally {
Expand Down
Expand Up @@ -83,7 +83,7 @@ public LargeMessageTestBase(StoreConfiguration.StoreType storeType) {
public void tearDown() throws Exception {
super.tearDown();
if (storeType == StoreConfiguration.StoreType.DATABASE) {
destroyTables(Arrays.asList("BINDINGS", "LARGE_MESSAGE", "MESSAGE"));
destroyTables(Arrays.asList("BINDINGS", "LARGE_MESSAGE", "MESSAGE", "NODE_MANAGER_STORE"));
}
}

Expand Down
Expand Up @@ -111,7 +111,7 @@ public void tearDown() throws Exception {

scheduledExecutorService.shutdown();

destroyTables(Arrays.asList(new String[]{"MESSAGE", "BINDINGS", "LARGE_MESSAGE"}));
destroyTables(Arrays.asList(new String[]{"MESSAGE", "BINDINGS", "LARGE_MESSAGE", "NODE_MANAGER_STORE"}));
super.tearDown();
if (exception != null)
throw exception;
Expand Down
Expand Up @@ -123,7 +123,7 @@ public void tearDown() throws Exception {
MBeanServerFactory.releaseMBeanServer(mbeanServer);
super.tearDown();
if (storeType == StoreConfiguration.StoreType.DATABASE) {
destroyTables(Arrays.asList("BINDINGS", "LARGE_MESSAGE", "MESSAGE"));
destroyTables(Arrays.asList("BINDINGS", "LARGE_MESSAGE", "MESSAGE", "NODE_MANAGER_STORE"));
}
}

Expand Down

0 comments on commit 8842ac3

Please sign in to comment.