Posts

Showing posts with the label DB

Postgres database connection for Spring app (Java 21)

Dependencies: &ltdependencies&gt &ltdependency&gt &ltgroupId&gtorg.postgresql&lt/groupId&gt &ltartifactId&gtpostgresql&lt/artifactId&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtorg.springframework.boot&lt/groupId&gt &ltartifactId&gtspring-boot-starter-data-jpa&lt/artifactId&gt &lt/dependency&gt &lt/dependencies&gt Properties short way: spring: datasource: url: jdbc:postgresql://localhost:5432/custom_database username: postgres password: password # if you want your app to auto create tables on start: # jpa: # hibernate: # ddl-auto: create And a little more advanced: spring: jpa: properties: hibernate: jdbc: time_zone: UTC datasource: url: jdbc:postgresql://localhost:5432/custom_database user...

Postgres database connection for Spring app (Java 11)

I’m using Postgres DB in almost all my projects because it’s good enough for most cases and FREE. This article describes how to connect Java&Spring app to a Postgres database. First of all – dependencies: &ltdependencies&gt &ltdependency&gt &ltgroupId&gtorg.postgresql&lt/groupId&gt &ltartifactId&gtpostgresql&lt/artifactId&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtorg.springframework.boot&lt/groupId&gt &ltartifactId&gtspring-boot-starter-data-jpa&lt/artifactId&gt &lt/dependency&gt &lt/dependencies&gt Second, add properties. This is short way: spring: datasource: url: jdbc:postgresql://localhost:5432/custom_database username: postgres password: password # if you want your app to auto create tables on start: # jpa: # hibernate: # ...