Class DefaultJDBCAdapter
- java.lang.Object
-
- org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter
-
- All Implemented Interfaces:
JDBCAdapter
- Direct Known Subclasses:
BlobJDBCAdapter,BytesJDBCAdapter,DB2JDBCAdapter,ImageBasedJDBCAdaptor,MaxDBJDBCAdapter,MySqlJDBCAdapter,OracleJDBCAdapter,SqlServerJDBCAdapter,StreamJDBCAdapter
public class DefaultJDBCAdapter extends Object implements JDBCAdapter
Implements all the default JDBC operations that are used by the JDBCPersistenceAdapter. sub-classing is encouraged to override the default implementation of methods to account for differences in JDBC Driver implementations. The JDBCAdapter inserts and extracts BLOB data using the getBytes()/setBytes() operations. The databases/JDBC drivers that use this adapter are:
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanbatchStatmentsstatic intMAX_ROWSprotected intmaxRowsprotected booleanprioritizedMessagesprotected Statementsstatements
-
Constructor Summary
Constructors Constructor Description DefaultJDBCAdapter()
-
Method Summary
-
-
-
Field Detail
-
MAX_ROWS
public static final int MAX_ROWS
- See Also:
- Constant Field Values
-
statements
protected Statements statements
-
batchStatments
protected boolean batchStatments
-
prioritizedMessages
protected boolean prioritizedMessages
-
maxRows
protected int maxRows
-
-
Method Detail
-
setBinaryData
protected void setBinaryData(PreparedStatement s, int index, byte[] data) throws SQLException
- Throws:
SQLException
-
getBinaryData
protected byte[] getBinaryData(ResultSet rs, int index) throws SQLException
- Throws:
SQLException
-
doCreateTables
public void doCreateTables(TransactionContext transactionContext) throws SQLException, IOException
- Specified by:
doCreateTablesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDropTables
public void doDropTables(TransactionContext c) throws SQLException, IOException
- Specified by:
doDropTablesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetLastMessageStoreSequenceId
public long doGetLastMessageStoreSequenceId(TransactionContext c) throws SQLException, IOException
- Specified by:
doGetLastMessageStoreSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageById
public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException
- Specified by:
doGetMessageByIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doAddMessage
public void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration, byte priority, XATransactionId xid) throws SQLException, IOException
A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome- Specified by:
doAddMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doUpdateMessage
public void doUpdateMessage(TransactionContext c, ActiveMQDestination destination, MessageId id, byte[] data) throws SQLException, IOException
- Specified by:
doUpdateMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doAddMessageReference
public void doAddMessageReference(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, long expirationTime, String messageRef) throws SQLException, IOException
- Specified by:
doAddMessageReferencein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
getStoreSequenceId
public long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException
- Specified by:
getStoreSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessage
public byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException
- Specified by:
doGetMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageReference
public String doGetMessageReference(TransactionContext c, long seq) throws SQLException, IOException
- Specified by:
doGetMessageReferencein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRemoveMessage
public void doRemoveMessage(TransactionContext c, long seq, XATransactionId xid) throws SQLException, IOException
A non null xid indicated the op is part of 2pc prepare, so ops are flagged pending outcome- Specified by:
doRemoveMessagein interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecover
public void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverin interfaceJDBCAdapter- Throws:
Exception
-
doMessageIdScan
public void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) throws SQLException, IOException
- Specified by:
doMessageIdScanin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetLastAckWithPriority
public void doSetLastAckWithPriority(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException
- Specified by:
doSetLastAckWithPriorityin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetLastAck
public void doSetLastAck(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException
- Specified by:
doSetLastAckin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doClearLastAck
public void doClearLastAck(TransactionContext c, ActiveMQDestination destination, byte priority, String clientId, String subName) throws SQLException, IOException
- Specified by:
doClearLastAckin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverSubscription
public void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverSubscriptionin interfaceJDBCAdapter- Throws:
Exception
-
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverNextMessagesin interfaceJDBCAdapter- Throws:
Exception
-
doRecoverNextMessagesWithPriority
public void doRecoverNextMessagesWithPriority(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverNextMessagesWithPriorityin interfaceJDBCAdapter- Throws:
Exception
-
doGetDurableSubscriberMessageCount
public int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizedMessages) throws SQLException, IOException
- Specified by:
doGetDurableSubscriberMessageCountin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doSetSubscriberEntry
public void doSetSubscriberEntry(TransactionContext c, SubscriptionInfo info, boolean retroactive, boolean isPrioritizedMessages) throws SQLException, IOException
- Specified by:
doSetSubscriberEntryin interfaceJDBCAdapter- Parameters:
c-info-retroactive-- Throws:
SQLExceptionIOException
-
doGetSubscriberEntry
public SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException
- Specified by:
doGetSubscriberEntryin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetAllSubscriptions
public SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doGetAllSubscriptionsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRemoveAllMessages
public void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName) throws SQLException, IOException
- Specified by:
doRemoveAllMessagesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDeleteSubscription
public void doDeleteSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException
- Specified by:
doDeleteSubscriptionin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doDeleteOldMessages
public void doDeleteOldMessages(TransactionContext c) throws SQLException, IOException
- Specified by:
doDeleteOldMessagesin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetLastAckedDurableSubscriberMessageId
public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName) throws SQLException, IOException
- Specified by:
doGetLastAckedDurableSubscriberMessageIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
close
protected static void close(PreparedStatement s)
-
close
protected static void close(ResultSet rs)
-
doGetDestinations
public Set<ActiveMQDestination> doGetDestinations(TransactionContext c) throws SQLException, IOException
- Specified by:
doGetDestinationsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
isBatchStatements
public boolean isBatchStatements()
- Returns:
- true if batchStatements
-
setBatchStatements
public void setBatchStatements(boolean batchStatements)
Set the number of statements to process as a single batch DB update- Parameters:
batchStatements-
-
isBatchStatments
public boolean isBatchStatments()
- Returns:
- true if batchStements
-
setBatchStatments
public void setBatchStatments(boolean batchStatments)
Deprecated.This value batchStatments is deprecated and will be removed in a future release. Use batchStatements instead (Note the 'e' in Statement)"- Parameters:
batchStatments-
-
setUseExternalMessageReferences
public void setUseExternalMessageReferences(boolean useExternalMessageReferences)
- Specified by:
setUseExternalMessageReferencesin interfaceJDBCAdapter
-
getStatements
public Statements getStatements()
- Returns:
- the statements
-
setStatements
public void setStatements(Statements statements)
- Specified by:
setStatementsin interfaceJDBCAdapter
-
getMaxRows
public int getMaxRows()
- Specified by:
getMaxRowsin interfaceJDBCAdapter
-
setMaxRows
public void setMaxRows(int maxRows)
the max value for statement maxRows, used to limit jdbc queries- Specified by:
setMaxRowsin interfaceJDBCAdapter
-
doRecordDestination
public void doRecordDestination(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doRecordDestinationin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverPreparedOps
public void doRecoverPreparedOps(TransactionContext c, JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws SQLException, IOException
- Specified by:
doRecoverPreparedOpsin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doCommitAddOp
public void doCommitAddOp(TransactionContext c, long preparedSequence, long sequence) throws SQLException, IOException
- Specified by:
doCommitAddOpin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doGetMessageCount
public int doGetMessageCount(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doGetMessageCountin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, long[] lastRecoveredEntries, long maxSeq, int maxReturned, boolean isPrioritizedMessages, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverNextMessagesin interfaceJDBCAdapter- Throws:
Exception
-
doGetLastProducerSequenceId
public long doGetLastProducerSequenceId(TransactionContext c, ProducerId id) throws SQLException, IOException
- Specified by:
doGetLastProducerSequenceIdin interfaceJDBCAdapter- Throws:
SQLExceptionIOException
-
dumpTables
public static void dumpTables(Connection c, String destinationName, String clientId, String subscriptionName) throws SQLException
- Throws:
SQLException
-
dumpTables
public static void dumpTables(Connection c) throws SQLException
- Throws:
SQLException
-
printQuery
public static void printQuery(Connection c, String query, PrintStream out) throws SQLException
- Throws:
SQLException
-
printQuery
public static void printQuery(PreparedStatement s, PrintStream out) throws SQLException
- Throws:
SQLException
-
limitQuery
public String limitQuery(String query)
- Specified by:
limitQueryin interfaceJDBCAdapter
-
-