blob: 41ce333a8f70e4cf313dc052993c780197ff6101 [file] [log] [blame]
<div class="wiki-content maincontent"><p>We support a range of SQL databases for message persistence such as</p><ul><li>Apache Derby</li><li>Axion</li><li>DB2</li><li>HSQL</li><li>Informix</li><li>MaxDB</li><li>MySQL</li><li>Oracle</li><li>Postgresql</li><li><link><page ri:content-title="SQLServer"></page></link></li><li><link><page ri:content-title="Sybase"></page></link></li></ul><p>as well as a number of generic JDBC providers.</p><h3>Auto-discovery of your JDBC provider</h3><p>We try to auto-detect from the JDBC driver which JDBCAdapter to use via these <a shape="rect" href="https://git-wip-us.apache.org/repos/asf?p=activemq.git;a=tree;f=activemq-jdbc-store/src/main/resources/META-INF/services/org/apache/activemq/store/jdbc">config files</a> and the return string from the JDBC driver.</p><p>If you have a JDBC database which we don't support then please let us know what JDBC driver string you're getting and <link><page ri:content-title="Discussion Forums"></page><plain-text-link-body>drop us a note</plain-text-link-body></link> or raise an issue in our <a shape="rect" href="http://issues.apache.org/activemq/browse/AMQ">support database</a> and we'll fix it pretty quickly.</p><p>If your database is not in the above list it is normally a matter of tweaking the StatementProvider to ensure that the JDBCMessageStore uses the right flavour of SQL. So normally most databases support one of these providers...</p><ul><li>org.activemq.store.jdbc.adapter.BlobJDBCAdapter</li><li>org.activemq.store.jdbc.adapter.BytesJDBCAdapter</li><li>org.activemq.store.jdbc.adapter.DefaultJDBCAdapter</li><li>org.activemq.store.jdbc.adapter.ImageJDBCAdapter</li></ul><p>You can explicitly specify the JDBC adaptor using its xbean identifier, inside the activemq.xml...</p><structured-macro ac:macro-id="45d22476-142f-4b05-8879-76bd163c8efe" ac:name="code" ac:schema-version="1"><parameter ac:name="">xml</parameter><plain-text-body>&lt;jdbcPersistenceAdapter adapter="postgresql-jdbc-adapter"/&gt;
</plain-text-body></structured-macro><h3>Customizing the SQL DDL</h3><p>You can confiugure the various SQL datatypes - such as column sizes and so forth - using the statements element</p><structured-macro ac:macro-id="28fb77cc-b99c-46bb-a02a-5bb4f4df4f81" ac:name="code" ac:schema-version="1"><plain-text-body> &lt;broker useJmx="false"&gt;
&lt;persistenceAdapter&gt;
&lt;journaledJDBC useJournal="false"&gt;
&lt;statements&gt;
&lt;statements stringIdDataType ="VARCHAR(128)"/&gt;
&lt;/statements&gt;
&lt;/journaledJDBC&gt;
&lt;/persistenceAdapter&gt;
&lt;/broker&gt;
</plain-text-body></structured-macro><p>For more info on what attributes can be set on the statements element, see the <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/store/jdbc/Statements.html">Statements class</a>. All the settable bean properties can be used as attributes of the &lt;statements&gt; element.</p><h3>Using MySQL</h3><p>If you are using MySQL then you should set the <strong>relaxAutoCommit</strong> flag to be true. e.g.</p><structured-macro ac:macro-id="150457bb-9c29-40d2-b917-8bca8441f5d7" ac:name="code" ac:schema-version="1"><plain-text-body> &lt;bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
&lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
&lt;property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/&gt;
&lt;property name="username" value="activemq"/&gt;
&lt;property name="password" value="activemq"/&gt;
&lt;property name="poolPreparedStatements" value="true"/&gt;
&lt;/bean&gt;
</plain-text-body></structured-macro><p>To see this in action see the <a shape="rect" href="http://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/conf/activemq.xml">default configuration file</a></p><h3>For AMQ 3.x</h3><p>In 3.x you can specify the adapter as follows</p><structured-macro ac:macro-id="8a41d054-c2d5-4b21-84f7-c430ace0b29c" ac:name="code" ac:schema-version="1"><parameter ac:name="">xml</parameter><plain-text-body>&lt;jdbcPersistence adapterClass="org.activemq.store.jdbc.adapter.ImageBasedJDBCAdaptor"&gt;
...
&lt;/jdbcPersistence&gt;
</plain-text-body></structured-macro></div>