Administrator

Lokesh Gupta

A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies. An avid Sci-Fi movie enthusiast and a fan of Christopher Nolan and Quentin Tarantino.

Website: https://howtodoinjava.com

Github: https://github.com/lokeshgupta1981/

Twitter: @HowToDoInJAVA

LinkedIn: https://www.linkedin.com/in/lokeshgupta1981/

My Articles:

Selenide IllegalArgumentException: Failed to create folders

The error “java.lang.IllegalArgumentException: Failed to create folder” in Selenide typically happens when Selenide tries to save screenshots, page sources, or logs, but it cannot create the required directories due to permission issues or incorrect paths.

Angular UI Testing using Selenium and Selenide

In-browser UI testing of Angular applications poses several challenges such as asynchronous operations and unpredictable loading screens with spinners or dimmers.
Selenide has an implicit capability to wait for the loading screen to disappear.

How to Fix MySQL Innodb_Force_Recovery Not Working Issue?

When InnoDB tables become corrupted, the InnoDB storage engine typically crashes the MySQL server to prevent further damage. In such situations, you can use the innodb_force_recovery option to force the server to start despite the corruption. However, you may face a situation where the innodb_force_recovery fails to start the server. …

JPackage : Create MSI/EXE Installer for Java App

The jpackage is a command-line tool introduced in Java 14 and helps create native installable packages (.exe, .msi, .dmg, .pkg, .deb, .rpm) for Windows, macOS, and Linux. Jpackage bundles Java applications along with a Java runtime (JRE) image, ensuring that end users do not need to install Java separately.

How to Use DBCC CHECKDB to Check the Integrity Check in SQL DB

Database integrity refers to the accuracy, consistency, and reliability of the data stored within a database. It ensures that data remains uncorrupted, and adheres to defined rules. In SQL databases, integrity is supported through constraints like primary keys, foreign keys, unique constraints, and check constraints, alongside physical and logical data …

TypeScript Array of Objects

In TypeScript, an array of objects is a collection of items where each item is an object. Arrays of objects are commonly used to organize complex data structures, such as user information, products, or any other entity, into manageable collections.

TypeScript Array of Vectors: Multi-dimensional Arrays

In TypeScript, an array of vectors is a collection of vectors, where each vector can represent an array of numbers or custom objects. This multi-dimensional array structure is handy in scenarios such as mathematical computations, graphics programming, or handling grouped data in a type-safe and organized manner.

Python Read File Line by Line (with Examples)

Python provides several ways to read a text file and process its lines sequentially or randomly. The correct method to use depends on the size of the file (large or small) and the ease of desired syntax. In this Python tutorial, we will discuss different approaches based on their clean …

How to Remove Orphan Entities in Hibernate?

In Hibernate, an orphan entity refers to a child entity that has been disassociated from its parent. If these orphan entities are not explicitly removed, they remain in the database and result in unwanted data. The orphanRemoval = true attribute on the mapping annotation on parent entity automatically removes the …

How to Save Child Entities using Hibernate?

One of the most essential concepts in Hibernate is working with parent-child entity relationships, where a parent entity contains references to one or more child entities. To ensure that we are saving/updating the child entities (along with the parent entity), we depend on the correct usage of annotations like @OneToOne, …

Logback.xml File Configuration Example

This short Logback tutorial lists examples for configuring logback.xml to log messages to both the console and/or file appenders. 1. Logback Dependencies To include Logback, include the latest version of logback-classic dependency, which transitively includes all the necessary dependencies, including SLF4J. Spring Boot comes with SLF4J and Logback as the …

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 …

[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 …

Log4j2 YAML File Example

Learn to configure log4j2.yaml file to output the log statements to the console, rolling files, etc. Also, learn to configure log4j2 appenders, levels, and patterns.

Spring Boot WebClient GET Example

Learn to make HTTP GET requests (sync and async) using Spring Boot WebClient, pass URI and query params, handle responses, and handle errors.

Java Object Equality without Public Fields or Getters

As a best practice in Java, POJO classes or Data objects always declare the fields private and expose their access through the getter methods. On rare occasions, we may encounter situations when the member fields are private, and the class does not provide the public accessor methods. For example, the …

Spring AI Function Calling Example

In Spring AI, function calling is the ability for the model to request one or more function calls to be made on its behalf by the ChatBot application.

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. …

Spring AI Speech to Text Example

Spring AI currently supports only OpenAI’s whisper model for speech transcription to JSON or TEXT files using OpenAiAudioTranscriptionModel class.

How to Create Immutable Map in Java?

Learn to create an immutable or unmodifiable Map using the factory methods added in Java 9 and other versions (Java 8 to Java 21) with examples.

Serialize Object to String in Java

In Java, we can serialize an object to String in different ways such as converting to byte[] and thenBase64 encoded string, XML or JSON. Learn with examples.

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.

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.