0

I've developed an application using JSP, Spring Security, MySql. I deployed it on Cloudfoundry. But just war file and I binded mysql service. But I also have to configure MySQL database that consists of two tables, new user and it all in my own database. While i tested my application on localhost i prepared the database running manual scripts in MySQL command window. Question: How can I make the same configurations in CloudFoundry? can I the same way run all commands and scripts manually or export the database somehow? if yes, how to do this. And what to write here now instead of localhost?

 <property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/security_filter" />

thank you

user1379574
  • 689
  • 4
  • 11
  • 23

2 Answers2

1

Caldecott (vmc tunnel) is the correct way to access your cloudoundry database (for me it works and i am using ruby 1.8): http://docs.cloudfoundry.com/tools/vmc/caldecott.html

If that does not work for you you will have to do something manually (much harder):

  • Create a sample jsp/servlet application that connects to a mysql database (retrieving connection string, username and password as input from user). Then it will just run the sql statement against the database ( sql statement will be also input from user)
  • Bundle this application in your war
  • Now you have to retrieve database connection string/username and password. You can retrieve them from the enviromental variable VCAP_SERVICES. Just log log it in a startup listener (eg ServletContextListener)
  • Deploy your war and get logs from server (vmc logs ApplicationName). Get connection string, username and password
  • Logon to your application and use your database application to access the database using the db info you collected in the previous step

Just note that this is very dangerous approach. Just be sure to secure this database application or after the initial import remove it from your war and redeploy the application

As a final note you can check if such a database console application already exists so that you dont have to create your own (for example grails has a nice application for this http://grails.org/plugin/dbconsole. Maybe something exists for jsp/servlets)

Hope it helps if you have no luck with the ruby problem

Glenn Oppegard
  • 1,139
  • 5
  • 11
dimcookies
  • 1,930
  • 7
  • 31
  • 37
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 at: http://docs.cloudfoundry.com/tools/vmc/caldecott.html

Ali Moghadam
  • 1,270
  • 8
  • 17