You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Navin Naidu <na...@gmail.com> on 2010/08/26 15:07:14 UTC

How to programmatically configure JDBC Persistence.

Hi,

How can I programmatically configure for jdbc persistence with apache derby.


Is this the right way to configure ?

Snippet:
**********************************************************************************************************

BrokerService broker = *new* BrokerService();

JDBCPersistenceAdapter jdbc= *new* JDBCPersistenceAdapter();

EmbeddedDataSource dataSource = *new* EmbeddedDataSource();

dataSource.setDatabaseName("derbyDb");

dataSource.setCreateDatabase("create");

jdbc.setDataDirectory("SampleData");

jdbc.setDataSource(dataSource);

broker.setUseJmx(*true*);

broker.setPersistent(*true*);

broker.setPersistenceAdapter(jdbc);

broker.addConnector("tcp://localhost:61616");

broker.start();
**********************************************************************************************************

The "derbyDb" database is created, as well as the default data directory of
activemq "activemq-data" is also getting created. But somehow "SampleData"
is not getting created.

Can I configure the persistence programmatically, or do I have to use the
config file.

-- 
Thanks & Regards,

- Navin

Re: How to programmatically configure JDBC Persistence.

Posted by Gary Tully <ga...@gmail.com>.
Have a look at this example from the tests (there are a few more in
the same directory):
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapterTest.java?view=markup

On 26 August 2010 14:07, Navin Naidu <na...@gmail.com> wrote:
> Hi,
>
> How can I programmatically configure for jdbc persistence with apache derby.
>
>
> Is this the right way to configure ?
>
> Snippet:
> **********************************************************************************************************
>
> BrokerService broker = *new* BrokerService();
>
> JDBCPersistenceAdapter jdbc= *new* JDBCPersistenceAdapter();
>
> EmbeddedDataSource dataSource = *new* EmbeddedDataSource();
>
> dataSource.setDatabaseName("derbyDb");
>
> dataSource.setCreateDatabase("create");
>
> jdbc.setDataDirectory("SampleData");
>
> jdbc.setDataSource(dataSource);
>
> broker.setUseJmx(*true*);
>
> broker.setPersistent(*true*);
>
> broker.setPersistenceAdapter(jdbc);
>
> broker.addConnector("tcp://localhost:61616");
>
> broker.start();
> **********************************************************************************************************
>
> The "derbyDb" database is created, as well as the default data directory of
> activemq "activemq-data" is also getting created. But somehow "SampleData"
> is not getting created.
>
> Can I configure the persistence programmatically, or do I have to use the
> config file.
>
> --
> Thanks & Regards,
>
> - Navin
>



-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com