| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
| <title>ActiveMQ</title> |
| <link rel="icon" type="image/png" href="/assets/img/favicon.png"> |
| |
| <link rel="stylesheet" href="/css/main.css"> |
| <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" integrity="sha384-SlE991lGASHoBfWbelyBPLsUlwY1GwNDJo3jSJO04KZ33K2bwfV9YBauFfnzvynJ" crossorigin="anonymous"></script> |
| <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> |
| <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> |
| </head> |
| |
| <body> |
| <nav class="navbar navbar-expand-lg navbar-light fixed-top"> |
| <div class="container"> |
| <!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> --> |
| <a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a> |
| <button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation"> |
| <span class="navbar-toggler-icon"></span> |
| </button> |
| |
| <div class="ml-auto collapse navbar-collapse" id="navbarContent"> |
| <ul class="navbar-nav ml-auto"> |
| <li class="nav-item"> |
| <a class="nav-link active" href="/index.html">Home</a> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components</a> |
| <ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents"> |
| <div class="row"> |
| <div class="col-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ 5</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Contact</a> |
| <ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity"> |
| <div class="row"> |
| <div class="col-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="/contact#mailing">Mailing Lists</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/contact#chat">Chat</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/contact#issues">Report Issues</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/contact#contributing">Contributing</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| <li class="nav-item dropdown"> |
| <a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a> |
| <ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam"> |
| <div class="row"> |
| <div class="col-sm-12"> |
| <ul class="multi-column-dropdown"> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li> |
| <li class="nav-item"><a class="dropdown-item" href="/team/reports">Board Reports</a></li> |
| </ul> |
| </div> |
| </div> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </nav> |
| |
| <div class="content"> |
| <div class="page-title-activemq5"> |
| <div class="container"> |
| <h1>JDBC Support</h1> |
| </div> |
| </div> |
| <div class="container" > |
| <div class="row" style="margin-top: 30px"> |
| <div class="col-12 activemq5"> |
| <p><a href="features">Features</a> > <a href="persistence">Persistence</a> > <a href="jdbc-support">JDBC Support</a></p> |
| |
| <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><a href="Persistence/JDBC Support/sqlserver">SQLServer</a></li> |
| <li><a href="Persistence/JDBC Support/sybase">Sybase</a></li> |
| </ul> |
| |
| <p>as well as a number of generic JDBC providers.</p> |
| |
| <h3 id="auto-discovery-of-your-jdbc-provider">Auto-discovery of your JDBC provider</h3> |
| |
| <p>We try to auto-detect from the JDBC driver which JDBCAdapter to use via these <a 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 <a href="discussion-forums">drop us a note</a> or raise an issue in our <a 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> |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><jdbcPersistenceAdapter adapter="postgresql-jdbc-adapter"/> |
| </code></pre></div></div> |
| |
| <h3 id="customizing-the-sql-ddl">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> |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><broker useJmx="false"> |
| |
| <persistenceAdapter> |
| <journaledJDBC useJournal="false"> |
| <statements> |
| <statements stringIdDataType ="VARCHAR(128)"/> |
| </statements> |
| </journaledJDBC> |
| </persistenceAdapter> |
| |
| </broker> |
| </code></pre></div></div> |
| <p>For more info on what attributes can be set on the statements element, see the <a 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 <statements> element.</statements></p> |
| |
| <h3 id="using-mysql">Using MySQL</h3> |
| |
| <p>If you are using MySQL then you should set the <strong>relaxAutoCommit</strong> flag to be true. e.g.</p> |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> |
| <property name="driverClassName" value="com.mysql.jdbc.Driver"/> |
| <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"/> |
| <property name="username" value="activemq"/> |
| <property name="password" value="activemq"/> |
| <property name="poolPreparedStatements" value="true"/> |
| </bean> |
| </code></pre></div></div> |
| <p>To see this in action see the <a href="http://svn.apache.org/repos/asf/activemq/trunk/assembly/src/release/conf/activemq.xml">default configuration file</a></p> |
| |
| <h3 id="for-amq-3x">For AMQ 3.x</h3> |
| |
| <p>In 3.x you can specify the adapter as follows</p> |
| <div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code><jdbcPersistence adapterClass="org.activemq.store.jdbc.adapter.ImageBasedJDBCAdaptor"> |
| ... |
| </jdbcPersistence> |
| </code></pre></div></div> |
| |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="row sitemap"> |
| <div class="col-sm-12"> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-sm-12"> |
| <div class="row"> |
| <div class="col-sm-3"> |
| <div > |
| <img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/> |
| </div> |
| </div> |
| <div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6"> |
| <p>Apache ActiveMQ, ActiveMQ, ActiveMQ Artemis, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2019, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p> |
| </div> |
| <div class="col-sm-3"> |
| <div > |
| <a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </body> |
| </html> |