7 Replies Latest reply on Apr 16, 2009 10:35 PM by ?? gao

    How to set the datasource inside ServiceMix??

    ?? gao Newbie

      How to set the data source inside ServiceMix, initialization, as well as connect to database??

      Such as mysql database, how to %SERVICEMIX_HOME%\conf the following configuration Jndi.xml?


      Edited by: gaoming25 on Mar 11, 2009 10:03 AM

        • 1. Re: How to set the datasource inside ServiceMix??
          Stan Lewis Novice

          Adding JNDI datasources to servicemix is documented here for 3.x:




          if you're starting servicemix directly the "conf" directory will already be in your classpath, whereas if you're embedding servicemix within a servlet container you'll need to ensure the container is configured to include the "conf" directory in the classpath so servicemix can find the jndi.properties file.

          • 2. Re: How to set the datasource inside ServiceMix??
            Torsten Mielke Apprentice

            Do you want to use MySQL as the persistence store in the embedded ActiveMQ? This can be configured easily and is documented here

            Simply uncomment the line

                  <amq:journaledJDBC journalLogFiles="5" 

            in your conf/activemq.xml and set the dataSource property to the #mysql-ds reference. Further down in the same file uncomment the mysql-ds bean definition and configure it properly for url, username and password.

            You will also need to place the MySQL JDBC driver into lib/optional of your ServiceMix installation.

            • 3. Re: How to set the datasource inside ServiceMix??
              ?? gao Newbie

              I ask my brother, how to deploy ServiceMix the following data sources? ?


              Where to deploy? Can support multiple data sources&#21527;? Supported connection


              pool management? Posted the best section of the configuration of mysql and


              oracle code? thanks !!

              • 4. Re: How to set the datasource inside ServiceMix??
                Torsten Mielke Apprentice

                If you want to configure the underlying ActiveMQ to use JDBC for persistence (can you please confirm this?), then only one JDBC driver can be configured at a time.


                Connection pooling is provided by using the Jakarta Commons DBCP library, as already configured in your activemq.xml:


                <bean id="mysql-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
                    <property name="url" value="jdbc:mysql://localhost/activemq?relaxAutoCommit=true"></property>
                    <property name="username" value="activemq"></property>
                    <property name="password" value="activemq"></property>
                    <property name="maxActive" value="200"></property>
                    <property name="poolPreparedStatements" value="true"></property>


                Perhaps you also find this documentation useful. For Oracle I also suggest reading the documentation of their JDBC driver.

                • 5. Re: How to set the datasource inside ServiceMix??
                  ?? gao Newbie

                  thank very much!!!


                  I have configured JNDI will, but if I create a new project to achieve a database (mysql) operation, such as: add, delete, modify, operate, how to do? ? ? Have you source it?

                  I see there are spagic components jdbc, how to connect and databases, and operating it?

                  Can give me a database operated source project?


                  Edited by: gaoming25 on Mar 19, 2009 3:45 AM

                  • 6. Re: How to set the datasource inside ServiceMix??
                    Torsten Mielke Apprentice

                    Do you want to use MySQL in your application level code? Well, then just resolve the driver or JDBC connection from JNDI and use it from there.

                    I presume you configured MySQL via Spring?


                    Not sure if I understand your question right though.

                    • 7. Re: How to set the datasource inside ServiceMix??
                      ?? gao Newbie

                      Thank you very much! In jndi.xml, mysql is configured to have the will, but this oracle? ? With those drivers?


                      My Profile:


                      However, can not be inserted into the data, you can query!


                      this is the Exception &#65306;


                      Exception in thread "pool-3-thread-1" java.lang.AbstractMethodError: oracle.jdbc



                              at org.apache.commons.dbcp.DelegatingPreparedStatement.getParameterMetaD


                              at org.glassfish.openesb.databasebc.JDBCDenormalizer.populatePreparedSta


                              at org.glassfish.openesb.databasebc.JDBCDenormalizer.denormalizeOutbound


                              at org.glassfish.openesb.databasebc.OutboundMessageProcessor.executeOutb


                              at org.glassfish.openesb.databasebc.OutboundMessageProcessor.processInOn


                              at org.glassfish.openesb.databasebc.OutboundMessageProcessor.execute(Out


                              at org.glassfish.openesb.databasebc.OutboundMessageProcessor.run(Outboun


                              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec


                              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor


                              at java.lang.Thread.run(Thread.java:619)


                      Edited by: gaoming25 on Apr 17, 2009 2:33 AM