0

I'd like to ask about database behavior on CloudFoundry service. I'm using Spring and vmc as my deploying command line helper. When I deploy an application and bind a service (in my case MySQL), user can add data to my service and those informations are stored in the database, which is ok. But after some time, when noone use my application (i'm talking about days), database is emptied. The same happens when I redeploy my application.

So my question is: database storage on CloudFoundry is not "persistent" (=forever), so should I search for some database hosting? Or how does this work?

shmoula
  • 1,053
  • 2
  • 10
  • 33

2 Answers2

1

Normally that shouldn't happen. Ensure that when you redeploy your application you select the same service you had created the first time the application was uploaded otherwise a new service will be created for the application leading to an empty database

dimcookies
  • 1,930
  • 7
  • 31
  • 37
  • I'm absolutely sure about this. It looks like database is emptied after each restart. When I do 'vmc stop app' and then 'vmc start app', my data are gone. It looks like 'DataSource' isn't propertly autoconfigured for some reason. – shmoula May 17 '12 at 09:11
  • When I do `vmc stop app` and `vmc start app` my MySQL data remains. So it's not a universal problem. There must be a configuration issue. – mdahlman May 17 '12 at 20:14
  • Based on [this](http://docs.cloudfoundry.com/frameworks/java/spring/spring.html#determining-whether-your-application-can-be-auto-configured) I believe that if I create simple roo project and deploy it, start it, fill some data, stop it and start again, it keeps its data. But it doesnt! – shmoula May 17 '12 at 20:40
  • Man, I found it!! I had create set on hibernate.hbm2ddl.auto property in persistence.xml, after I changed it, stop and start doesnt remove data! Following comment is above that node: value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database – shmoula May 17 '12 at 20:48
  • hi guys ..i am doing the same thing .. but i am getting problem in attatching my own database with my application i have bind service giving any name to it as it asks for hmm but how will i attatch my own database which is stored in .sql file in my system with my application ...please help me in telling steps of how to do it – Vishal Sharma May 24 '12 at 14:48
0

You would need to create a mysqldump of your database. Once you have the mysqldump file, you then use caldecott and perform vmc tunnel to your MySQL service. After you have establish a connection with your MySQL service on Cloud Foundry, you then need to use the mysql command to manually import the mysqldump file into your service.

For how to use vmc tunnel, visit the documentation site here.

Timothée Jeannin
  • 9,652
  • 2
  • 56
  • 65
eightyoctane
  • 639
  • 3
  • 6