JDBC

spring data jpa is better !

pom.xml

<!-- for jdbc -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>

<!-- for migrations of table to db -->
<dependency>
	<groupId>org.flywaydb</groupId>
	<artifactId>flyway-core</artifactId>
</dependency>

Configuration for PostgreSQL

For flyway migration

  • If you are using Flyway for db migration, create a folder db/migrations inside resource folder

    • Name the migration V[number]__[name of migration].sql

    • Example : V1__InitTables.sql

Configuring HikariDataSource

Queries

RowMapper<T>

Last updated

Was this helpful?