Bluemix Liberty SQLDB

94 Views Asked by At

I have created an "enterprise template" Liberty server with an EAR file application requiring a few SQLDB connections. This is working and I am able to cf push this server to the Bluemix environment.

My question is how do I go about packaging the entire content and publish this to Bluemix in ONE action (i.e., they will have an instance of the same application running on Liberty with the same SQLDB table setup).

From my quick browsing of the blogs and Q&A, I have only found articles talking about creating the SQLDB ahead of time, packaging the Liberty runtime as a .zip file, and then using cf push to Bluemix. Because the SQLDB was created ahead of time, the DB connections would work.

So is there a way to package the Liberty server with the SQLDB creation as one entity into perhaps one "buildpack"? If so, can someone guide me on the steps involved? (or articles/blogs, anything would help)

2

There are 2 best solutions below

0
On

You can't do it.

If you want create a script that do all operations in one time, an idea is create a simple job (in java for example) that you can launch in your script.

The job should perform these steps:

  1. connect to sqldb - bluemix service using VCAP_SERVICES (for this step you can see the documentation https://www.ng.bluemix.net/docs/#services/SQLDB/index.html#SQLDB
  2. run DDL (create table, ...) in your little job
  3. close connection
0
On

Another option is to package a database migration helper (something like Flyway in the application. Then you can invoke it using Java, on application startup (we've had good luck with @singleton @startup EJBs for this pattern). The migration will run when needed, but leave the database alone otherwise. Another advantage of this pattern is you can use the migrations to update the tables of an existing table (as the name suggests).