Log4j2 JDBCAppender

Learn to configure the Log4j2 provided JDBCAppender that writes log events to a relational database table using standard JDBC. The JDBCAppender obtains the database connection from a configured connection factory or JNDI datasource. Then it uses the provided column configuration to insert a new row in the log table, everytime a log statement is executed. … Read more

Hibernate Search Example with Lucene and Spring Boot

The Hibernate Search module works as a bridge between Hibernate ORM and full-text search engines such as Lucene or Elasticsearch. While performing a search, it enables us to work with JPA entities, and in the background, it transparently works with Lucene to provide a consistent experience. This Hibernate search guide will discuss the core concepts … Read more

[Solved] CommandAcceptanceException: Error executing DDL

1. Problem When writing tests that depend on H2 database in a Spring boot application, we may encounter the CommandAcceptanceException: Error executing DDL. The root cause exception will be org.h2.jdbc.JdbcSQLSyntaxErrorException in the logs. The exception stack trace will look something like this: If you are trying to run unit tests with the H2 database and … Read more

Spring AI Tutorial

Inspired by LangChain4j and LlamaIndex, Spring AI project aims to streamline the development and integration of AI capabilities into existing or new Spring applications.

Query Relation Database using GenAI and Spring AI

LLMs are quite good at producing the source code when they are provided enough context information and asked very clear questions. The same is true for generating SQL queries when they are provided the table/column information through DDL statements, and clear instructions of output format of the generated SQL statements. Let us see a quick … Read more

Spring Boot JpaRepository Example

Learn to Spring Data JPA module and work with JpaRepository interface for performing the CRUD operations in underlying databases in a Spring Boot application.

Spring Boot and Vaadin CRUD Example

Vaadin is a Java framework that simplifies front-end development by providing a rich set of reusable UI components and layouts. In this Spring Boot and Vaadin tutorial, we will explore the process of developing a basic CRUD application. 1. Goals Our goal is to construct a user interface that includes a table displaying the list … Read more

Spring Boot @ServiceConnection

Since Spring Boot 3.1, @ServiceConnection is used to provide connection details to a remote service that takes precedence over details in the properties file.

Spring Security Interview Questions

If you’re preparing for a job interview, these Spring security interview questions will help you understand key concepts and increase the confidence.

Redis Pub/Sub with Spring Boot Data

Learn to use Redis Pub/Sub with Spring Boot Data, and configure the message publishers and subscribers (listners) for a given channel topic.

Spring Security Tutorial

In Spring security tutorial, learn how it works under the hood, concepts of authentication, authorization, access control and basic configurations.

Getting Started with Keycloak on Docker

Learn the installation of the Keycloak authorization server as a docker container and different configurations for setting up the realm and testing the authorization token flow.

Configure Multiple DataSources in Spring Boot

In this post, we will learn how to configure and manage multiple datasources using properties configuration and defining custom beans using Java annotations in Spring Boot. Note that this requirement differs from having separate datasource in test, dev and prod environments. Here, we are using multiple datasources in the same environment and each datasource can … Read more

Spring Boot – Separate DataSource for Test, Dev and Prod

Learn to configure and use different DataSource in different environments (test, development, production etc.) using the Spring profile specific properties files, as well as Java configuration in a Spring boot application. 1. Introduction A production grade application is deployed and tested in different environments before finally released to the end-user. In these environments, application must … Read more

Spring Batch Tutorial

Spring batch is a lightweight, comprehensive framework designed for the development of robust batch processing applications. Learn with examples.

SQL Interview Questions with Answers

This guide lists out a few of the most asked SQL interview questions and gives their answers such as JOINS, KEYWORDS, TRIGGERS and much more.

Java Versions and Features [Updated upto Java 22]

On this page, we will frequently list the major feature changes in the latest Java release, sequentially. Though we have tried to cover as much information as possible, if you know something we have missed below, please let me know, and we will add that information. Java 22 Features Java 22 has been released on … Read more

Spring Boot Profiles

Learn about Spring profiles, @Profile, profile-specific beans and properties, profile groups and activating a certain profile during startup.

Accessing Properties in Spring Boot

Learn to use @PropertySource, @Value and @ConfigurationProperties annotations to register property files and inject configuration properties.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.