How can i connect java application to postgresql database

PostgreSQL is a powerful, open-source SQL database with an object-relational structure and numerous robust features to ensure excellent performance and reliability. In this tutorial, we’ll show how to connect postgreSQL database with Java application hosted with Jelastic PaaS.

1. Login to your cloudjiffy account

2. Create Java environment with PostgreSQL database:

         

3. Check my e-mail - in inbox should have a message with the database login and credentails
   

                                               

                                                          
4. Click the Config button next to your application server (Tomcat in our case) to access the configuration file manager and create a new mydb.cfg file in the /opt/tomcat/temp folder.
 

5. Add all necessary configurations:

host=jdbc:postgresql://postgres{node_id}-{my_env_name}.{hoster_domain}/{db_name}

username={get in the email from CloudJiffy}

password={get in the email from CloudJiffy}

driver=org.postgresql.Driver


       
 

6. Deploy our example application to your Tomcat server. Due to different version servlet specifications supported by Tomcat 9 and Tomcat 10 we have prepared the respective applications:

For Tomcat 9: https://download.jelastic.com/public.php?service=files&t=18753849900d2461b3162bd4355f834d&download

For Tomcat 10: https://download.jelastic.com/public.php?service=files&t=503e9768ee573fd452cec8a34a2215b2&download






9. Click Open in Browser next to the application server
 


10. Click Open in Browser next to the PostgreSQL database node to see the created table in the database Admin panel.


Was this article helpful?

mood_bad Dislike 0
mood Like 0
visibility Views: 15547