How to connect java application with Mysql database

MySQL is a highly popular open source database, used by developers all over the world. In this instruction, we’ll show how to connect Java application, hosted within Cloudjiffy, to this Mysql DB server.

1. Login to your Cloudjiffy account.

2. Create a new environment with the MySQL database server (available within the SQL wizard section):

3. Check your email inbox - you should have received a mail with Mysql credentials.

                           

4. Switch back to the dashboard and click the Open in browser button for the MySQL node. Log in to the opened phpMyadmin panel using the above mentioned credentials and create a new database (for example, mysqlconnection).

                               

5. Then, click the Config button next to the application server, In the opened tab, create a new mydb.cfg file inside the /opt/tomcat/temp folder.

 

6. Add the following MySQL connection strings to the created mydb.cfg file.

host=jdbc:mysql://{mysql_node_id}-{my_env_name}.{hoster_domain}/{db_name}
username={get it in the email from Cloudjiffy}
password={get it in the email from Cloudjiffy}
driver=com.mysql.jdbc.Driver

 

7. Download the example project from the below link and deploy it into the environment.

   

10. Now click Open in the browser next to the application server.

works fine, click Open in the browser next to my MySQL node and navigate to the previously created mysqlconnection database in the opened admin panel. I’ll see the new example table appeared in it, which means the DB has been successfully accessed from the deployed Java application.

It’s that simple!


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 16695