<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tonykaynoni</title>
    <description>The latest articles on DEV Community by Tonykaynoni (@tonykaynoni).</description>
    <link>https://dev.to/tonykaynoni</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F207920%2Fb7f77b57-8c29-4db6-87ad-dc27719fcfbd.jpeg</url>
      <title>DEV Community: Tonykaynoni</title>
      <link>https://dev.to/tonykaynoni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tonykaynoni"/>
    <language>en</language>
    <item>
      <title>How to connect a SpringBoot Application to PostgreSQL on your windows local machine</title>
      <dc:creator>Tonykaynoni</dc:creator>
      <pubDate>Mon, 20 Mar 2023 04:10:36 +0000</pubDate>
      <link>https://dev.to/tonykaynoni/how-to-connect-a-springboot-application-to-postgresql-on-your-windows-local-machine-20ij</link>
      <guid>https://dev.to/tonykaynoni/how-to-connect-a-springboot-application-to-postgresql-on-your-windows-local-machine-20ij</guid>
      <description>&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;br&gt;
PostgreSQL is a general-purpose and object-relational database management system, and one of the most advanced open-source database system. In this article, we will learn how to link a Spring-Boot application with PostgreSQL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xjLhIQiT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ucb703dh1ehznkb9fcr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xjLhIQiT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ucb703dh1ehznkb9fcr.png" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.enterprisedb.com/downloads/postgres-postgresql-downloads"&gt;Download and install PostgreSQL&lt;/a&gt;. You must take note of the details you entered during PostgreSQL installation, it will be used to access your database later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;br&gt;
Search for and Open "SQL shell" on your machine, click enter four times and enter your password if any exist. Create a database using&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE DATABASE databaseName;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xHK7uags--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpa4d5cvotqb6sddbdeq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xHK7uags--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpa4d5cvotqb6sddbdeq.png" alt="Image description" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt;&lt;br&gt;
Create your spring boot application and add Postgres to the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;br&gt;
Add the following to your application.properties file,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;server.port=9009 //projectPort&lt;br&gt;
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect&lt;br&gt;
spring.jpa.hibernate.show-sql=true&lt;br&gt;
spring.datasource.url=jdbc:postgresql://localhost:5432/databasename spring.datasource.username=postgres //postgressUser&lt;br&gt;
spring.datasource.password=yourPostgressPassword &lt;br&gt;
spring.datasource.initialization-mode=always&lt;br&gt;
spring.datasource.initialize=true&lt;br&gt;
spring.datasource.continue-on-error=true&lt;br&gt;
spring.jpa.hibernate.ddl-auto=update&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With these steps, Postgres is already included and connected to your project.&lt;br&gt;
You can now use Spring Data JPA repository to save and retrieve data from your database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To view your project using PgAdmin&lt;br&gt;
Step 1.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/r/?url=https%3A%2F%2Fwww.pgadmin.org%2Fdownload%2F"&gt;Download and install PgAdmin&lt;/a&gt; - If you checked PgAdmin during PostgresSql installation skip this step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt;&lt;br&gt;
Open PgAdmin and Right-click on "servers" and click "create", then "server".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3.&lt;/strong&gt; &lt;br&gt;
Give the server a name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--otpoyHRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjxbrgon4lwchoc21z0t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--otpoyHRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjxbrgon4lwchoc21z0t.png" alt="Image description" width="498" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4.&lt;/strong&gt;&lt;br&gt;
Navigate to connection on the "create-server panel", and fill your database details as follows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z3A8mkAm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hdlnvz195h5y5dv26mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z3A8mkAm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hdlnvz195h5y5dv26mo.png" alt="Image description" width="504" height="551"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that, the password is the same with the password used during Postgres installation, and you can check your database Owner(user) by using your SQL shell with the command "\L"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YagNGGar--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fcq9jim4rwx6lktb06k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YagNGGar--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9fcq9jim4rwx6lktb06k.png" alt="Image description" width="800" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 - &lt;/strong&gt;&lt;br&gt;
Click save, then you can now view your database on PgAdmin.&lt;/p&gt;

&lt;p&gt;Please add your comments, Thanks for reading.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
