Database Articles
7 articles about Database. Explore Spring Boot implementation, design, and operations across related topics.
-
How to Retrieve the Auto-Generated ID (AUTO_INCREMENT) After INSERT with Spring Boot + MyBatis
This article explains how to reflect the AUTO_INCREMENT/IDENTITY value generated by the DB after an INSERT in MyBatis back into your Java entity, covering both the annotation-based approach and the XML-based approach. It also introduces an alternative implementation using selectKey, and how to diagnose the typical causes when the ID comes back as 0/null.
-
Causes and Fixes for HikariCP "Failed to validate connection" and "Connection is closed" in Spring Boot - How to Decide maxLifetime and keepaliveTime
Learn how to isolate HikariCP "Failed to validate connection" and "Connection is closed" errors by pool stage, how to derive maxLifetime and keepaliveTime from DB and network timeouts, and how to diagnose why the pool does not recover after a DB restart.
-
How to Connect Spring Boot to MySQL - application.yml Configuration, JDBC URL Parameters, and Time Zone/Character Encoding Pitfalls
A step-by-step guide to connecting Spring Boot 3.x to MySQL 8, covering Docker Compose startup, application.yml configuration, and connectivity checks. Also covers recommended JDBC URL parameter values and how to fix the Public Key Retrieval error, date/time offsets, and utf8mb4 garbled characters.
-
Database Migration Management with Liquibase in Spring Boot
A guide to introducing Liquibase in Spring Boot, covering XML/YAML/SQL changelog notation, how to write changeSets, executing rollbacks, and comparison and selection criteria against Flyway, complete with implementation code.
-
How to Properly Configure and Tune HikariCP Connection Pool in Spring Boot - Why the Default of 10 Isn't Enough
A tuning guide to eliminate Connection is not available errors in Spring Boot's HikariCP. Covers the maximumPoolSize default of 10 versus the official formula (cores × 2 + 1), revisiting connectionTimeout from 30 seconds to 3 seconds, the relationship between maxLifetime and wait_timeout, and leak detection with leakDetectionThreshold, all with implementation examples. Includes comparative data showing how configuration review reduced the timeout error rate from 40% to 3%.
-
Database Migration Management with Flyway in Spring Boot - A Guide from Version Control to Production Deployment
A practical guide to safely version-controlling your database schema using Flyway in Spring Boot applications. Covers introducing spring-boot-starter-flyway, configuring application.properties, how the flyway_schema_history table works, handling existing databases with baseline-on-migrate, and troubleshooting with flywayRepair, all explained with concrete examples.
-
Introduction to JPA Association Mapping in Spring Boot - How to Use @OneToMany/@ManyToOne/@ManyToMany and mappedBy
A beginner-friendly guide to @OneToMany, @ManyToOne, @ManyToMany, and mappedBy in Spring Boot JPA. Covers bidirectional vs. unidirectional relationships, cascade, FetchType, the N+1 problem, and circular reference handling with code examples to resolve common pitfalls.