JPA2 and CloudBees

Posted by: Matthias Wessendorf on 02/12/2011

Besides its “Tomcat-as-a-Service”, the CloudBees service is also offering a hosted MySQL (5.0.51) database. This “database-as-a-service” can be used in various ways. Once you’ve created your database, you can get detailed informations about it in the management console. This console includes a few code samples on how-to configure the hosted database, e.g to be used in JSP or ColdFusion.

Of course, you can also use JPA inside of the CloudBees offer. I’ve tested it with EclipseLink and OpenJPA.

In order to use JPA with the hosted database, you need to include something like below, in your persistence.xml file:

<persistence-unit
  name="myUnit"
  transaction-type="RESOURCE_LOCAL">

<class>my.PersistentObject</class>
...

 <properties>
<!-- JPA standard properties -->
<property
   name="javax.persistence.jdbc.driver"
   value="com.cloudbees.jdbc.Driver"/>
<property
   name="javax.persistence.jdbc.url"
   value="jdbc:cloudbees://YOURSCHEMA"/>
<property
   name="javax.persistence.jdbc.user"
   value="USER"/>
<property
   name="javax.persistence.jdbc.password"
   value="PASSWORD"/>
....

That’s all you need! Now you are able to use the database!

Note: For your local development you can also access the DB via a real URL and the regular MySQL driver. The management console does show the remote connection details as well.



About Matthias Wessendorf

Matthias  Wessendorf

Matthias Wessendorf is a software developer at Oracle. He currently works on ADF Faces, which is an Ajax-based JSF component suite. Matthias also contributes to the OpenSource community, mainly Apache MyFaces and Apache Trinidad. Before joining Oracle, he worked as a CMS-Developer at pironet, where he was building a next-generation CMS, using UI technologies like XUL and Ajax.

More About Matthias »

Northern Virginia Software Symposium

November 1 - 3, 2013

Reston, VA

Current Topics on the NFJS Tour

  • Core Java, JEE
  • Dynamic Languages: Groovy, JRuby, Scala, Clojure
  • RESTful Web Apps
  • Frameworks: Hibernate, Grails, Spring, JSF, GWT, more
  • Agility
  • Test Driven Design
  • Security
  • Ajax, Flex, RIA
View Event Details »

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 7
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 3
  • Automation Tools: Git, Hudson, Sonar
  • HTML5, Ajax, jQuery, Usability
  • Mobile Applications - iPhone and Android
  • More...
Learn More »

NFJS, the Magazine

May Issue Now Available
  • On the road to learning

    by Raju Gandhi
  • Refactoring to Modularity

    by Kirk Knoernschild
  • RESTful Groovy

    by Kenneth Kousen
  • Getting Started with D3.js

    by Brian Sletten
Learn More »