}
public void insert(Connection connection, String storeId, Message message) throws SQLException, JMSException
{
final String destinationName = message.getJMSDestination() == null ? "default" : JMSUtils.getDestinationName(message.getJMSDestination());
final Domain domain = message.getJMSDestination() == null ? Domain.QUEUE : Domain.getDomain(message.getJMSDestination());
final String messageAsXMLString = xmlHelper.toXML(message);
final InputStream messageAsXML = new StringInputStream(messageAsXMLString);
final String messageId = getNextMessageId(storeId);
//
// DBUtils does not seem to correctly deal with CLOBS, so we have to use
// normal JDBC...
//
// runner.update(connection, "insert into messages values (?, ?)", new
// Object[] { message.getJMSMessageID(), messageAsXML });
final PreparedStatement pstmt = connection.prepareStatement("insert into messages values (?, ?)");
pstmt.setString(1, messageId);
pstmt.setAsciiStream(2, messageAsXML, messageAsXMLString.length());
pstmt.execute();
pstmt.close();
final QueryRunner runner = new QueryRunner();
runner.update(connection, "insert into stores values (?, ?, ?, ?)", new Object[] { storeId, destinationName, domain.getId(), messageId });
}