Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Gemini JPA / DBAccess - best way to configure JDBC properties?(How can I maintain DB connection info in a separate properties file?)
Gemini JPA / DBAccess - best way to configure JDBC properties? [message #1002312] Fri, 18 January 2013 06:36 Go to next message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
I've just migrated an OSGi application to Gemini JPA / DBAccess with MySQL, running on Virgo 3.6. Currently I have the jdbc connection property values set in the persistence.xml file. Is it possible to store these properties in a separate configuration file? I'd like to change files for different environments e.g. development, production.

Previously, I had my own OSGi bundle which created a datasource using a C3P0 connection pool. This used a property-placeholder bean which referenced a configuration artefact loaded by Virgo:

<!--  Create a connection pool data source (using C3P0 lib) for the DB -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
             p:driverClass="${db.driverClass}"
             p:jdbcUrl="${db.url}"
             p:user="${db.username}"
             p:password="${db.password}"
             />

     <context:property-placeholder properties-ref="configProperties"/>

     <osgi-compendium:cm-properties id="configProperties" persistent-id="db_config"/>

     <!-- ========================= OSGi SERVICES ========================= -->

     <osgi:service ref="dataSource" interface="javax.sql.DataSource"/>
Re: Gemini JPA / DBAccess - best way to configure JDBC properties? [message #1002376 is a reply to message #1002312] Fri, 18 January 2013 08:32 Go to previous messageGo to next message
Mike Keith is currently offline Mike Keith
Messages: 211
Registered: July 2009
Senior Member
First, Gemini JPA supports multiple persistence descriptors so you can break things up statically that way.
Second, there is support for dynamic definition using the OSGi config admin service. See http://wiki.eclipse.org/Gemini/JPA/Documentation/OtherTopics#Configuration_Admin

-Mike
Re: Gemini JPA / DBAccess - best way to configure JDBC properties? [message #1003604 is a reply to message #1002312] Mon, 21 January 2013 10:45 Go to previous message
Simon Watson is currently offline Simon Watson
Messages: 30
Registered: September 2011
Member
Thanks Mike. I will investigate using the config admin service.
Previous Topic:Gemini JPA and Spring
Next Topic:List of Services: Wait for all Services?
Goto Forum:
  


Current Time: Fri Jul 25 16:47:50 EDT 2014

Powered by FUDForum. Page generated in 0.03668 seconds