Sixth, open the query tool by choosing the menu item Tool > Query Tool or click the lightning icon. By default, PostgreSQL has a database named postgres as shown below: Third, enter the server name e.g., PostgreSQL and click the Connection tab:įourth, enter the host and password for the postgres user and click the Save button:įifth, click on the Servers node to expand the server. Second, right-click the Servers node and select Create > Server… menu to create a server The pgAdmin application will launch on the web browser as shown in the following picture: The following illustrates how to connect to a database using pgAdmin GUI application: The pgAdmin application allows you to interact with the PostgreSQL database server via an intuitive user interface. The second way to connect to a database is by using a pgAdmin application. 2) Connect to PostgreSQL database server using pgAdmin
After pressing Enter, psql will return the current PostgreSQL version on your system. Please do not forget to end the statement with a semicolon ( ). SELECT version() Code language: SQL (Structured Query Language) ( sql ) The following statement returns the current version of PostgreSQL: Third, interact with the PostgreSQL Database Server by issuing an SQL statement. In the step for entering the password for user postgres, you need to enter the password the user postgres that you chose during the PostgreSQL installation. For example, localhost is the default database server. If you press Enter, the program will use the default value specified in the square bracket and move the cursor to the new line. Second, enter all the information such as Server, Database, Port, Username, and Password. The following steps show you how to connect to the PostgreSQL database server via the psql program:įirst, launch the psql program and connect to the PostgreSQL Database Server using the postgres user: It allows you to interact with the PostgreSQL database server such as executing SQL statements and managing database objects. Psql is an interactive terminal program provided by PostgreSQL.
Let’s access our database via phpPgAdmin to ensure that a new table was created (access credentials are provided via the email described in the second step of this guide).Īs you can see, a new table (named due to the date and time of the creation) has been successfully added by our Java application. Your request will be processed shortly displaying the result message.ĩ. Within the opened browser tab, click the Create test table in your database button. After successful deployment, click Open in Browser next to your application server.Ĩ. Host=jdbc:postgresql:// /WEB-INF/lib folder on your application server (don’t forget to restart server afterward to apply the changes).ħ.
Provide the following connection details in the mydb.cfg file: 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.Ĥ. After creation, you’ll receive an email with your database access credentials (host, login, and password).ģ. Log into Jelastic dashboard, create New Environment with the Java application server and the PostgreSQL database.Ģ. In this tutorial, we’ll show how to connect PostgreSQL database with Java application hosted with Jelastic PaaS.ġ. PostgreSQL is a powerful, open source SQL database with the object-relational structure and numerous robust features to ensure excellent performance and reliability.