throws ConfigException, SQLException
{
_messageTable = _jdbcManager.getMessageTable();
_dataSource = _jdbcManager.getDataSource();
JdbcMetaData metaData = _jdbcManager.getMetaData();
_isOracle = metaData instanceof OracleMetaData;
String longType = _jdbcManager.getLongType();
String identity = longType + " PRIMARY KEY";
if (metaData.supportsIdentity())
identity = metaData.createIdentitySQL(identity);
else
_messageSequence = _messageTable + "_cseq";
Connection conn = _dataSource.getConnection();
try {
Statement stmt = conn.createStatement();
String sql = "SELECT 1 FROM " + _messageTable + " WHERE 1=0";
try {
ResultSet rs = stmt.executeQuery(sql);
rs.next();
rs.close();
stmt.close();
return;
} catch (SQLException e) {
log.finest(e.toString());
}
String blob = _jdbcManager.getBlob();
log.info(L.l("creating JMS message table {0}", _messageTable));
sql = ("CREATE TABLE " + _messageTable + " (" +
" m_id " + identity + "," +
" queue INTEGER NOT NULL," +
" conn VARCHAR(255)," +
" consumer " + longType + "," +
" delivered INTEGER NOT NULL," +
" msg_type INTEGER NOT NULL," +
" msg_id VARCHAR(64) NOT NULL," +
" priority INTEGER NOT NULL," +
" expire " + longType + " NOT NULL," +
" header " + blob + "," +
" body " + blob +
")");
if (_isOracle) {
String extent = "";
if (_jdbcManager.getTablespace() != null) {
extent = " tablespace " + _jdbcManager.getTablespace();
}
// oracle recommends using retention (over pctversion) for performance
// Oracle will keep deleted lobs for the retention time before
// releasing them (e.g. 900 seconds)
sql += (" LOB(header) STORE AS (cache retention" + extent + ")");
sql += (" LOB(body) STORE AS (cache retention" + extent + ")");
}
stmt.executeUpdate(sql);
if (_messageSequence != null) {
stmt.executeUpdate(metaData.createSequenceSQL(_messageSequence, 1));
}
} finally {
conn.close();
}
}