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 boolean
batchStatments
static int
MAX_ROWS
protected int
maxRows
protected boolean
prioritizedMessages
protected Statements
statements
-
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:
doCreateTables
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doDropTables
public void doDropTables(TransactionContext c) throws SQLException, IOException
- Specified by:
doDropTables
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetLastMessageStoreSequenceId
public long doGetLastMessageStoreSequenceId(TransactionContext c) throws SQLException, IOException
- Specified by:
doGetLastMessageStoreSequenceId
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetMessageById
public byte[] doGetMessageById(TransactionContext c, long storeSequenceId) throws SQLException, IOException
- Specified by:
doGetMessageById
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
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:
doAddMessage
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doUpdateMessage
public void doUpdateMessage(TransactionContext c, ActiveMQDestination destination, MessageId id, byte[] data) throws SQLException, IOException
- Specified by:
doUpdateMessage
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doAddMessageReference
public void doAddMessageReference(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, long expirationTime, String messageRef) throws SQLException, IOException
- Specified by:
doAddMessageReference
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
getStoreSequenceId
public long[] getStoreSequenceId(TransactionContext c, ActiveMQDestination destination, MessageId messageID) throws SQLException, IOException
- Specified by:
getStoreSequenceId
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetMessage
public byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException
- Specified by:
doGetMessage
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetMessageReference
public String doGetMessageReference(TransactionContext c, long seq) throws SQLException, IOException
- Specified by:
doGetMessageReference
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
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:
doRemoveMessage
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doRecover
public void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecover
in interfaceJDBCAdapter
- Throws:
Exception
-
doMessageIdScan
public void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener) throws SQLException, IOException
- Specified by:
doMessageIdScan
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doSetLastAckWithPriority
public void doSetLastAckWithPriority(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException
- Specified by:
doSetLastAckWithPriority
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doSetLastAck
public void doSetLastAck(TransactionContext c, ActiveMQDestination destination, XATransactionId xid, String clientId, String subscriptionName, long seq, long priority) throws SQLException, IOException
- Specified by:
doSetLastAck
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doClearLastAck
public void doClearLastAck(TransactionContext c, ActiveMQDestination destination, byte priority, String clientId, String subName) throws SQLException, IOException
- Specified by:
doClearLastAck
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doRecoverSubscription
public void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverSubscription
in 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:
doRecoverNextMessages
in 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:
doRecoverNextMessagesWithPriority
in interfaceJDBCAdapter
- Throws:
Exception
-
doGetDurableSubscriberMessageCount
public int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, boolean isPrioritizedMessages) throws SQLException, IOException
- Specified by:
doGetDurableSubscriberMessageCount
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doSetSubscriberEntry
public void doSetSubscriberEntry(TransactionContext c, SubscriptionInfo info, boolean retroactive, boolean isPrioritizedMessages) throws SQLException, IOException
- Specified by:
doSetSubscriberEntry
in interfaceJDBCAdapter
- Parameters:
c
-info
-retroactive
-- Throws:
SQLException
IOException
-
doGetSubscriberEntry
public SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException
- Specified by:
doGetSubscriberEntry
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetAllSubscriptions
public SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doGetAllSubscriptions
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doRemoveAllMessages
public void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName) throws SQLException, IOException
- Specified by:
doRemoveAllMessages
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doDeleteSubscription
public void doDeleteSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName) throws SQLException, IOException
- Specified by:
doDeleteSubscription
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doDeleteOldMessages
public void doDeleteOldMessages(TransactionContext c) throws SQLException, IOException
- Specified by:
doDeleteOldMessages
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetLastAckedDurableSubscriberMessageId
public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName) throws SQLException, IOException
- Specified by:
doGetLastAckedDurableSubscriberMessageId
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
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:
doGetDestinations
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
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:
setUseExternalMessageReferences
in interfaceJDBCAdapter
-
getStatements
public Statements getStatements()
- Returns:
- the statements
-
setStatements
public void setStatements(Statements statements)
- Specified by:
setStatements
in interfaceJDBCAdapter
-
getMaxRows
public int getMaxRows()
- Specified by:
getMaxRows
in interfaceJDBCAdapter
-
setMaxRows
public void setMaxRows(int maxRows)
the max value for statement maxRows, used to limit jdbc queries- Specified by:
setMaxRows
in interfaceJDBCAdapter
-
doRecordDestination
public void doRecordDestination(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doRecordDestination
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doRecoverPreparedOps
public void doRecoverPreparedOps(TransactionContext c, JdbcMemoryTransactionStore jdbcMemoryTransactionStore) throws SQLException, IOException
- Specified by:
doRecoverPreparedOps
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doCommitAddOp
public void doCommitAddOp(TransactionContext c, long preparedSequence, long sequence) throws SQLException, IOException
- Specified by:
doCommitAddOp
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doGetMessageCount
public int doGetMessageCount(TransactionContext c, ActiveMQDestination destination) throws SQLException, IOException
- Specified by:
doGetMessageCount
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
doRecoverNextMessages
public void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, long[] lastRecoveredEntries, long maxSeq, int maxReturned, boolean isPrioritizedMessages, JDBCMessageRecoveryListener listener) throws Exception
- Specified by:
doRecoverNextMessages
in interfaceJDBCAdapter
- Throws:
Exception
-
doGetLastProducerSequenceId
public long doGetLastProducerSequenceId(TransactionContext c, ProducerId id) throws SQLException, IOException
- Specified by:
doGetLastProducerSequenceId
in interfaceJDBCAdapter
- Throws:
SQLException
IOException
-
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:
limitQuery
in interfaceJDBCAdapter
-
-