PostgreSQL Roo

Roo-PostgreSQL

Integrate PostgreSQL with Roo

This quickstart guide will help you to integrate your Roo application with PostgreSQL service on App42 PaaS.


Glossary

Kontena – Kontena is a lightweight container that will run your apps and services in an isolated and secured manner. You can specify the power of the Kontena while setting up infra or creating services. One Kontena power specifies to 256 MB Memory and 128 MHz CPU.

Service – Services in the App42 PaaS are add-on components which are needed in an App. App42 PaaS supports multiple services like SQL databases, NoSQL databases and more.

Prerequisites

To get going with App42 PaaS, below are few prerequisites that will allow you to use AppHQ – App42 PaaS Management Console as well as Command Line Client.


Creating Roo-PostgreSQL application
$ mkdir sampleRoo && cd sampleRoo
  $ roo
      ____  ____  ____
   / __ \/ __ \/ __ \
  / /_/ / / / / / / /
 / _, _/ /_/ / /_/ /
/_/ |_|\____/\____/    1.2.3.RELEASE [rev 7fd62b6]


Welcome to Spring Roo. For assistance press TAB or type "hint" then hit ENTER.
0 upgrades available (plus 35 upgrades not visible due to your version stability setting of RELEASE)

// create a topLevel package first
roo> project --topLevelPackage com.test
Created ROOT\pom.xml
Created SRC_MAIN_RESOURCES
Created SRC_MAIN_RESOURCES\log4j.properties
Created SPRING_CONFIG_ROOT
Created SPRING_CONFIG_ROOT\applicationContext.xml

// setup roo-postgreSQL
roo> persistence setup --provider HIBERNATE --database POSTGRES
Created SPRING_CONFIG_ROOT\database.properties
Please update your database details in src/main/resources/META-INF/spring/database.properties.
Updated SPRING_CONFIG_ROOT\applicationContext.xml
Created SRC_MAIN_RESOURCES\META-INF\persistence.xml
Updated ROOT\pom.xml [added dependencies postgresql:postgresql:9.1-901-1.jdbc4, org.hibernate:hibernate-
core:4.1.8.Final, org.hibernate:hibernate-entitymanager:4.1.8.Final, org.hibernate.javax.persistence:hib
ernate-jpa-2.0-api:1.0.1.Final, commons-collections:commons-collections:3.2.1, org.hibernate:hibernate-v
alidator:4.3.1.Final, javax.validation:validation-api:1.0.0.GA, cglib:cglib-nodep:2.2.2, javax.transacti
on:jta:1.1, org.springframework:spring-jdbc:${spring.version}, org.springframework:spring-orm:${spring.v
ersion}, commons-pool:commons-pool:1.5.6, commons-dbcp:commons-dbcp:1.3]

// now you will be able to use postgreSQL in your application
Configure postgreSQL credentials into Roo App

Once you have setup the Roo environment and created the PostgreSQL service, You need to configure the PostgreSQL credentials in your created Roo application.


database.driverClassName=org.postgresql.Driver
database.url=jdbc:postgresql://host:port/dbName
database.username=username
database.password=password

// host = service_host
// port = service_port
// dbName = service_database_name
// username = service_username
// password = service_password

You can also use our Sample Apps and extend it to suit your needs. Here is the link to Roo-PostgreSQL Sample App

Update Application

After doing all the modifications to your App, you need to update it on App42 PaaS to get the changes affected in your App running on App42 PaaS platform.

$ app42 update
Enter App Name: testRoo
1: Binary
2: Source
Choose Upload Type [Binary]: 2

Updating Application... OK

Operation is in progress, Please wait...-
App deployed successfully.