diff --git a/artemis-jdbc-store/pom.xml b/artemis-jdbc-store/pom.xml
index 86fe1a6e5b..80f69c4270 100644
--- a/artemis-jdbc-store/pom.xml
+++ b/artemis-jdbc-store/pom.xml
@@ -53,12 +53,19 @@
test
+
org.apache.derby
derby
test
+
+ org.postgresql
+ postgresql
+ provided
+
+
org.apache.activemq
artemis-journal
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
index bc04ab9316..8ce08c64e3 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/JDBCUtils.java
@@ -23,9 +23,13 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import org.apache.activemq.artemis.jdbc.store.file.sql.DerbySQLProvider;
-import org.apache.activemq.artemis.jdbc.store.file.sql.GenericSQLProvider;
-import org.apache.activemq.artemis.jdbc.store.file.sql.SQLProvider;
+import org.apache.activemq.artemis.jdbc.store.drivers.derby.DerbySQLProvider;
+import org.apache.activemq.artemis.jdbc.store.drivers.mysql.MySQLSQLProvider;
+import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSQLProvider;
+import org.apache.activemq.artemis.jdbc.store.drivers.postgres.PostgresSequentialSequentialFileDriver;
+import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver;
+import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
+import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
public class JDBCUtils {
@@ -69,8 +73,45 @@ public class JDBCUtils {
if (driverClass.contains("derby")) {
return new DerbySQLProvider(tableName);
}
+ else if (driverClass.contains("postgres")) {
+ return new PostgresSQLProvider(tableName);
+ }
+ else if (driverClass.contains("mysql")) {
+ return new MySQLSQLProvider(tableName);
+ }
else {
return new GenericSQLProvider(tableName);
}
}
+
+ public static JDBCSequentialFileFactoryDriver getDBFileDriver(String driverClass,
+ String tableName,
+ String jdbcConnectionUrl) throws SQLException {
+ JDBCSequentialFileFactoryDriver dbDriver;
+ if (driverClass.contains("derby")) {
+ dbDriver = new JDBCSequentialFileFactoryDriver();
+ dbDriver.setSqlProvider(new DerbySQLProvider(tableName));
+ dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
+ dbDriver.setJdbcDriverClass(driverClass);
+ }
+ else if (driverClass.contains("postgres")) {
+ dbDriver = new PostgresSequentialSequentialFileDriver();
+ dbDriver.setSqlProvider(new PostgresSQLProvider(tableName));
+ dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
+ dbDriver.setJdbcDriverClass(driverClass);
+ }
+ else if (driverClass.contains("mysql")) {
+ dbDriver = new JDBCSequentialFileFactoryDriver();
+ dbDriver.setSqlProvider(new MySQLSQLProvider(tableName));
+ dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
+ dbDriver.setJdbcDriverClass(driverClass);
+ }
+ else {
+ dbDriver = new JDBCSequentialFileFactoryDriver();
+ dbDriver.setSqlProvider(new GenericSQLProvider(tableName));
+ dbDriver.setJdbcConnectionUrl(jdbcConnectionUrl);
+ dbDriver.setJdbcDriverClass(driverClass);
+ }
+ return dbDriver;
+ }
}
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
new file mode 100644
index 0000000000..6d8be716fa
--- /dev/null
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.drivers;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import org.apache.activemq.artemis.jdbc.store.JDBCUtils;
+import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
+import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
+
+/**
+ * Class to hold common database functionality such as drivers and connections
+ */
+public abstract class AbstractJDBCDriver {
+
+ protected Connection connection;
+
+ protected SQLProvider sqlProvider;
+
+ protected String jdbcConnectionUrl;
+
+ protected String jdbcDriverClass;
+
+ protected Driver dbDriver;
+
+ public AbstractJDBCDriver() {
+ }
+
+ public AbstractJDBCDriver(String tableName, String jdbcConnectionUrl, String jdbcDriverClass) {
+ this.jdbcConnectionUrl = jdbcConnectionUrl;
+ this.jdbcDriverClass = jdbcDriverClass;
+ this.sqlProvider = JDBCUtils.getSQLProvider(jdbcDriverClass, tableName);
+ }
+
+ public void start() throws Exception {
+ connect();
+ createSchema();
+ prepareStatements();
+ }
+
+ public void stop() throws SQLException {
+ if (sqlProvider.closeConnectionOnShutdown()) {
+ connection.close();
+ }
+ }
+
+ protected abstract void prepareStatements() throws SQLException;
+
+ protected abstract void createSchema() throws SQLException;
+
+ protected void createTable(String schemaSql) throws SQLException {
+ JDBCUtils.createTableIfNotExists(connection, sqlProvider.getTableName(), schemaSql);
+ }
+
+ protected void connect() throws Exception {
+ try {
+ dbDriver = JDBCUtils.getDriver(jdbcDriverClass);
+ connection = dbDriver.connect(jdbcConnectionUrl, new Properties());
+ }
+ catch (SQLException e) {
+ ActiveMQJournalLogger.LOGGER.error("Unable to connect to database using URL: " + jdbcConnectionUrl);
+ throw new RuntimeException("Error connecting to database", e);
+ }
+ }
+
+ public void destroy() throws Exception {
+ try {
+ connection.setAutoCommit(false);
+ Statement statement = connection.createStatement();
+ statement.executeUpdate("DROP TABLE " + sqlProvider.getTableName());
+ statement.close();
+ connection.commit();
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+
+ public void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ public SQLProvider getSqlProvider() {
+ return sqlProvider;
+ }
+
+ public void setSqlProvider(SQLProvider sqlProvider) {
+ this.sqlProvider = sqlProvider;
+ }
+
+ public String getJdbcConnectionUrl() {
+ return jdbcConnectionUrl;
+ }
+
+ public void setJdbcConnectionUrl(String jdbcConnectionUrl) {
+ this.jdbcConnectionUrl = jdbcConnectionUrl;
+ }
+
+ public String getJdbcDriverClass() {
+ return jdbcDriverClass;
+ }
+
+ public void setJdbcDriverClass(String jdbcDriverClass) {
+ this.jdbcDriverClass = jdbcDriverClass;
+ }
+}
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/sql/DerbySQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/derby/DerbySQLProvider.java
similarity index 86%
rename from artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/sql/DerbySQLProvider.java
rename to artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/derby/DerbySQLProvider.java
index c14036ebbc..d9cbed4a7b 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/sql/DerbySQLProvider.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/derby/DerbySQLProvider.java
@@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.activemq.artemis.jdbc.store.file.sql;
+package org.apache.activemq.artemis.jdbc.store.drivers.derby;
+
+import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
public class DerbySQLProvider extends GenericSQLProvider {
@@ -46,7 +48,12 @@ public class DerbySQLProvider extends GenericSQLProvider {
}
@Override
- public String getAppendToFileSQL() {
+ public String getAppendToLargeObjectSQL() {
return appendToFileSQL;
}
+
+ @Override
+ public boolean closeConnectionOnShutdown() {
+ return false;
+ }
}
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
new file mode 100644
index 0000000000..1400382c0f
--- /dev/null
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/mysql/MySQLSQLProvider.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.drivers.mysql;
+
+import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
+
+public class MySQLSQLProvider extends GenericSQLProvider {
+
+ private static final int MAX_BLOB_SIZE = 4 * 1024 * 1024 * 1024; // 4GB
+
+ private final String createFileTableSQL;
+
+ private final String createJournalTableSQL;
+
+ private final String copyFileRecordByIdSQL;
+
+ public MySQLSQLProvider(String tName) {
+ super(tName.toLowerCase());
+
+ createFileTableSQL = "CREATE TABLE " + tableName +
+ "(ID INTEGER NOT NULL AUTO_INCREMENT," +
+ "FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA LONGBLOB, PRIMARY KEY(ID)) ENGINE=InnoDB;";
+
+ createJournalTableSQL = "CREATE TABLE " + tableName +
+ "(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record LONGBLOB,txDataSize INTEGER,txData LONGBLOB,txCheckNoRecords INTEGER,seq BIGINT) ENGINE=InnoDB;";
+
+ copyFileRecordByIdSQL = " UPDATE " + tableName + ", (SELECT DATA AS FROM_DATA FROM " + tableName +
+ " WHERE id=?) SELECT_COPY SET DATA=FROM_DATA WHERE id=?;";
+ }
+
+ @Override
+ public int getMaxBlobSize() {
+ return MAX_BLOB_SIZE;
+ }
+
+ @Override
+ public String getCreateFileTableSQL() {
+ return createFileTableSQL;
+ }
+
+ @Override
+ public String getCreateJournalTableSQL() {
+ return createJournalTableSQL;
+ }
+
+ @Override
+ public String getCopyFileRecordByIdSQL() {
+ return copyFileRecordByIdSQL;
+ }
+}
\ No newline at end of file
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
new file mode 100644
index 0000000000..664202b606
--- /dev/null
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSQLProvider.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.drivers.postgres;
+
+import org.apache.activemq.artemis.jdbc.store.sql.GenericSQLProvider;
+
+public class PostgresSQLProvider extends GenericSQLProvider {
+
+ // BYTEA Size used in Journal
+ private static final int MAX_BLOB_SIZE = 1024 * 1024 * 1024; // 1GB
+
+ private final String createFileTableSQL;
+
+ private final String createJournalTableSQL;
+
+ public PostgresSQLProvider(String tName) {
+ super(tName.toLowerCase());
+ createFileTableSQL = "CREATE TABLE " + tableName +
+ "(ID SERIAL, FILENAME VARCHAR(255), EXTENSION VARCHAR(10), DATA OID, PRIMARY KEY(ID))";
+
+ createJournalTableSQL = "CREATE TABLE " + tableName + "(id BIGINT,recordType SMALLINT,compactCount SMALLINT,txId BIGINT,userRecordType SMALLINT,variableSize INTEGER,record BYTEA,txDataSize INTEGER,txData BYTEA,txCheckNoRecords INTEGER,seq BIGINT)";
+ }
+
+ @Override
+ public String getCreateFileTableSQL() {
+ return createFileTableSQL;
+ }
+
+ @Override
+ public String getCreateJournalTableSQL() {
+ return createJournalTableSQL;
+ }
+
+ @Override
+ public int getMaxBlobSize() {
+ return MAX_BLOB_SIZE;
+ }
+}
+
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java
new file mode 100644
index 0000000000..4d42d7f223
--- /dev/null
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/postgres/PostgresSequentialSequentialFileDriver.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.jdbc.store.drivers.postgres;
+
+import java.nio.ByteBuffer;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactoryDriver;
+import org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile;
+import org.postgresql.PGConnection;
+import org.postgresql.largeobject.LargeObject;
+import org.postgresql.largeobject.LargeObjectManager;
+
+public class PostgresSequentialSequentialFileDriver extends JDBCSequentialFileFactoryDriver {
+
+ private static final String POSTGRES_OID_KEY = "POSTGRES_OID_KEY";
+
+ public PostgresSequentialSequentialFileDriver() throws SQLException {
+ super();
+ }
+
+ @Override
+ public synchronized void createFile(JDBCSequentialFile file) throws SQLException {
+ try {
+ connection.setAutoCommit(false);
+
+ LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
+ long oid = lobjManager.createLO();
+
+ createFile.setString(1, file.getFileName());
+ createFile.setString(2, file.getExtension());
+ createFile.setLong(3, oid);
+ createFile.executeUpdate();
+
+ try (ResultSet keys = createFile.getGeneratedKeys()) {
+ keys.next();
+ file.setId(keys.getInt(1));
+ }
+ connection.commit();
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+
+ @Override
+ public synchronized void loadFile(JDBCSequentialFile file) throws SQLException {
+ connection.setAutoCommit(false);
+ readLargeObject.setInt(1, file.getId());
+
+ try (ResultSet rs = readLargeObject.executeQuery()) {
+ if (rs.next()) {
+ file.setWritePosition(getPostGresLargeObjectSize(file));
+ }
+ connection.commit();
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+
+ @Override
+ public synchronized int writeToFile(JDBCSequentialFile file, byte[] data) throws SQLException {
+ LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
+ LargeObject largeObject = null;
+
+ Long oid = getOID(file);
+ try {
+ connection.setAutoCommit(false);
+ largeObject = lobjManager.open(oid, LargeObjectManager.WRITE);
+ largeObject.seek(largeObject.size());
+ largeObject.write(data);
+ largeObject.close();
+ connection.commit();
+ }
+ catch (Exception e) {
+ connection.rollback();
+ throw e;
+ }
+ return data.length;
+ }
+
+ @Override
+ public synchronized int readFromFile(JDBCSequentialFile file, ByteBuffer bytes) throws SQLException {
+ LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
+ LargeObject largeObject = null;
+ long oid = getOID(file);
+ try {
+ connection.setAutoCommit(false);
+ largeObject = lobjManager.open(oid, LargeObjectManager.READ);
+ int readLength = (int) calculateReadLength(largeObject.size(), bytes.remaining(), file.position());
+
+ if (readLength > 0) {
+ if (file.position() > 0) largeObject.seek((int) file.position());
+ byte[] data = largeObject.read(readLength);
+ bytes.put(data);
+ }
+
+ largeObject.close();
+ connection.commit();
+
+ return readLength;
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+
+ private synchronized Long getOID(JDBCSequentialFile file) throws SQLException {
+ Long oid = (Long) file.getMetaData(POSTGRES_OID_KEY);
+ if (oid == null) {
+ connection.setAutoCommit(false);
+ readLargeObject.setInt(1, file.getId());
+ try (ResultSet rs = readLargeObject.executeQuery()) {
+ if (rs.next()) {
+ file.addMetaData(POSTGRES_OID_KEY, rs.getLong(1));
+ }
+ connection.commit();
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+ if ((Long) file.getMetaData(POSTGRES_OID_KEY) == 0) {
+ System.out.println("FD");
+ }
+ return (Long) file.getMetaData(POSTGRES_OID_KEY);
+ }
+
+ private synchronized int getPostGresLargeObjectSize(JDBCSequentialFile file) throws SQLException {
+ LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
+
+ int size = 0;
+ Long oid = getOID(file);
+ if (oid != null) {
+ try {
+ connection.setAutoCommit(false);
+ LargeObject largeObject = lobjManager.open(oid, LargeObjectManager.READ);
+ size = largeObject.size();
+ largeObject.close();
+ connection.commit();
+ }
+ catch (SQLException e) {
+ connection.rollback();
+ throw e;
+ }
+ }
+ return size;
+ }
+}
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
index 73bec72314..5de876185a 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
@@ -19,24 +19,20 @@ package org.apache.activemq.artemis.jdbc.store.file;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.sql.Blob;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
import org.apache.activemq.artemis.core.io.IOCallback;
import org.apache.activemq.artemis.core.io.SequentialFile;
import org.apache.activemq.artemis.core.io.buffer.TimedBuffer;
import org.apache.activemq.artemis.core.journal.EncodingSupport;
import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback;
-import org.apache.activemq.artemis.jdbc.store.file.sql.SQLProvider;
-import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
import org.jboss.logging.Logger;
public class JDBCSequentialFile implements SequentialFile {
@@ -53,20 +49,6 @@ public class JDBCSequentialFile implements SequentialFile {
private int id = -1;
- private final PreparedStatement appendToFile;
-
- private final PreparedStatement deleteFile;
-
- private final PreparedStatement readFile;
-
- private final PreparedStatement createFile;
-
- private final PreparedStatement selectFileByFileName;
-
- private final PreparedStatement copyFileRecord;
-
- private final PreparedStatement renameFile;
-
private long readPosition = 0;
private long writePosition = 0;
@@ -75,33 +57,28 @@ public class JDBCSequentialFile implements SequentialFile {
private JDBCSequentialFileFactory fileFactory;
- private int maxSize;
-
- private SQLProvider sqlProvider;
-
private final Object writeLock;
+ private final JDBCSequentialFileFactoryDriver dbDriver;
+
+ // Allows DB Drivers to cache meta data.
+ private Map
+
+ org.postgresql
+ postgresql
+ 9.4-1205-jdbc4
+ provided
+
+
+
commons-collections
commons-collections-testframework
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 90f54254f8..b0303c7cb4 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -240,11 +240,20 @@
jboss-javaee
5.0.0.GA
+
+
org.apache.derby
derby
- ${apache.derby.version}
+ test
+
+
+ org.postgresql
+ postgresql
+ test
+
+
io.vertx
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java
index 6664d1ee09..03ed5b04cb 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/largemessage/LargeMessageTestBase.java
@@ -79,6 +79,13 @@ public abstract class LargeMessageTestBase extends ActiveMQTestBase {
this.storeType = storeType;
}
+ public void tearDown() throws Exception {
+ super.tearDown();
+ if (storeType == StoreConfiguration.StoreType.DATABASE) {
+ destroyTables(Arrays.asList("BINDINGS", "LARGE_MESSAGE", "MESSAGE"));
+ }
+ }
+
@Parameterized.Parameters(name = "storeType={0}")
public static Collection
+
+ org.apache.derby
+ derby
+ ${apache.derby.version}
+ test
+