Permalink
Browse files

Added support and instructions for datasources that supports the Open…

…Shift available databases
  • Loading branch information...
1 parent d52fbd9 commit 061113ea0196c52102dfba1a9edfd531100bbfc2 @fabianofranz fabianofranz committed Jul 4, 2012
View
19 README.md
@@ -23,19 +23,32 @@ Quickstart
git remote add upstream -m master git://github.com/fabianofranz/spring-eap6-quickstart.git
git pull -s recursive -X theirs upstream master
-4) Remove the default index.html file and commit
+4) Remove the default index.html file and commit:
git rm src/main/webapp/index.html
git commit -m 'Removed default index.html'
-5) Then push the repo upstream
+5) Then push the repo upstream:
git push
6) That's it, you can now browse to your application at:
http://spring-$yournamespace.rhcloud.com
+The example uses a H2 database configured and deployed by the application. You can easily change it to MySQL or PostgreSQL (available on OpenShift as cartridges):
+
+1) Add a database cartridge to your OpenShift app (mysql-5.1 or postgresql-8.4):
+
+ rhc app cartridge add -a spring -c mysql-5.1
+
+2) Change `persistence.xml` to use the appropriate datasource (java:jboss/datasources/MysqlDS or java:jboss/datasources/PostgreSQLDS):
+
+ <jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source>
+
+3) Commit and push your changes:
+
+ git commit -a -m 'Added MySQL database support'
+ git push
-The example uses the `java:jboss/datasources/SpringQuickstartDS` in-memory database, configured and deployed by the application.
View
6 src/main/resources/META-INF/persistence.xml
@@ -8,12 +8,12 @@
data source, this example data source is just for development and testing! -->
<!-- The datasource is deployed as WEB-INF/spring-quickstart-ds.xml, you
can find it in the source at src/main/webapp/WEB-INF/spring-quickstart-ds.xml -->
- <jta-data-source>java:jboss/datasources/SpringQuickstartDS</jta-data-source>
+ <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
<properties>
- <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/spring-quickstart/persistence" />
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/spring-quickstart/persistence" />
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
-</persistence>
+</persistence>
View
6 src/main/resources/META-INF/spring/infrastructure.xml
@@ -12,16 +12,14 @@
http://www.springframework.org/schema/jee/spring-jee.xsd">
<!-- JDNI name for EntityManagerFactory is defined in src/main/resources/META-INF/persistence.xml -->
- <jee:jndi-lookup jndi-name="java:jboss/spring-quickstart/persistence" id="entityManagerFactory"
+ <jee:jndi-lookup jndi-name="java:jboss/spring-quickstart/persistence" id="entityManagerFactory"
expected-type="javax.persistence.EntityManagerFactory" />
<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
- <jee:jndi-lookup jndi-name="java:jboss/datasources/SpringQuickstartDS" id="dataSource" expected-type="javax.sql.DataSource"/>
-
<tx:jta-transaction-manager />
-</beans>
+</beans>
View
2 src/main/resources/import.sql
@@ -1,3 +1,3 @@
-- You can use this file to load seed data into the database using SQL statements
insert into Member (id, name, email, phone_number) values (0, 'John Smith', 'john.smith@mailinator.com', '2125551212')
-insert into Member (id, name, email, phone_number) values (0, 'OpenShift, PaaS by Red Hat', 'openshift@redhat.com', '19197543700')
+insert into Member (id, name, email, phone_number) values (1, 'OpenShift PaaS by Red Hat', 'openshift@redhat.com', '19197543700')
View
12 src/main/webapp/WEB-INF/spring-quickstart-ds.xml
@@ -7,15 +7,5 @@
xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd">
<!-- The datasource is bound into JNDI at this location. We reference
this in META-INF/persistence.xml -->
- <datasource jndi-name="java:jboss/datasources/SpringQuickstartDS"
- pool-name="kitchensink-quickstart" enabled="true"
- use-java-context="true">
- <connection-url>jdbc:h2:mem:spring-eap6-quickstart;DB_CLOSE_DELAY=-1</connection-url>
- <driver>h2</driver>
- <security>
- <user-name>sa</user-name>
- <password>sa</password>
- </security>
- </datasource>
</datasources>
-
+

0 comments on commit 061113e

Please sign in to comment.