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:

[Solved] org.hibernate.QueryException: Cannot mix named and positional parameters

1. Reason we might face this exception if we are trying to execute stored procedure using JPA 2.1 and hibernate’s entity manager, and we are not using the entity manager’s registerStoredProcedureParameter() correctly. Incorrect usage may look like below OR the one you have written. The exception will look like this: …

Hibernate @NamedStoredProcedureQuery

Learn to execute SQL stored procedures with the help of @NamedStoredProcedureQuery annotation from Jakarta persistence API that helps in specifying the name of a stored procedure, its parameters, and its result type. 1. Project Setup The support for executing stored procedures using @NamedStoredProcedureQuery has been added in JPA 2.1. So …

Static Import Statements in Java

The static import statements import the static fields and methods from a class and allow them to be used without the class reference.

Java Access Modifiers

Java provides four access modifiers to set access levels for fields, methods and constructors i.e. public, private, protected, and default.

Java Class and Object

Classes are the basic units of programming in the object-oriented paradigm. In this tutorial, learn to write Java class and how to create object in Java.

Java continue Keyword

The Java continue statement skips the current iteration of a for loop, while loop, or do-while loop and moves to the next iteration.

Java break Statement

The break keyword in Java is used to terminate for, while, or do-while loops. It may also be used to terminate a switch statement as well.

Java Do-while

Java do-while loop executes the statements in do block, and then evaluates a condition in the while block to check whether to repeat the execution.

Java while Loop

The while loop in Java continually executes a block of statements until a particular condition evaluates to true, else the loop terminates.

Java For-each Loop

Since Java 1.5, the for-each loop or enhanced for loop is a concise way to iterate over the elements of an array and a Collection.

Java For Loop

Java for-loop statement is used to iterate over the arrays or collections using a counter variable that is incremented after each iteration.

Java Switch Statement

Java switch statements help in providing multiple possible execution paths for a program. Java switch statements can be used in place of if-else statements to write more cleaner and concise code. Java switch statements have evolved over time. In this tutorial, we will learn about basic switch statement features and …

Java If-else

Java if-else statements help the program execute the blocks of code only if the specified test condition evaluates to either true or false.

Block Statements in Java

A block statement is a sequence of zero or more statements enclosed in braces. A block statement is generally used to group together several statements, so they can be used in a situation that requires you to use a single statement. 1. What is a Block Statement? Generally, a java …

Types of Statements in Java

A statement specifies an action in a Java program. For example, a statement may tell the add of values of x and y and assign their sum to the variable z. It then prints a message to the standard output or writes data to a file, etc. Java statements can …

Java Operators

Learn about available Java operators, and precedence order and understand their usages with examples. We will also try to understand when to use which operator and what to expect in the result. 1. Java Operators An operator is a symbol that performs a specific operation on one, two, or three …

Little-Endian and Big-Endian in Java

We must have heard the terms Little-Endian and Big-Endian many times in your engineering course. Let’s quickly recap the concept behind these words. 1. Little-Endian vs Big-Endian These two terms are related to the direction of bytes in a word within CPU architecture. Computer memory is referenced by addresses that …

Java Data Types with Examples

Learn about various data types in Java. Learn the differences between primitive datatypes and non-primitive datatypes (or reference datatypes). We will also learn about the data types sizes and best practices for using datatypes in Java. 1. How to Declare a Variable in Java? In Java, typically datatypes are associated …

Introduction to Java Programming Language

Java is concurrent, object-oriented, and intended to let application developers “write once, run anywhere” (WORA). Java is considered a fast language, almost as fast as languages like C and Rust, but it uses a lot of memory in comparison to these languages. 1. What is Java Programming Language Java is …

Java Primitive Datatypes and Ranges

All the values in Java are divided into two categories: reference types and primitive types. Learn about eight Java primitive data types.

Field / Property / Mixed Access Modes in JPA

In JPA, mapping information of an entity must be accessible to the ORM provider at runtime, so that when it is writing the data to storage, mapping information can be obtained from the entity instance. Similarly, when the entity state is loaded from the storage, the provider runtime must be …

JPA Find Entity Example

Learn to find JPA entities by ID or name using EntityManager.find(), JPQL queries, named queries, Criteria API, and Spring Data repository methods.

JPA Delete Entity Example

JPA delete entity example. Learn to delete JPA entity by id. Also learn to delete multple jpa entities using Java Persistence Query Language.

Eclipse Quick Text Search Plugin

The eclipse quick search plugin is part of Spring Tools Suite (STS). So if you have STS installed in eclipse, then chances are you have it already.

Java Callable Future Example

One of the benefits of the Java executor framework is that we can run concurrent tasks that may return a single result after processing the tasks. The Java Concurrency API achieves this with the following two interfaces Callable and Future. In this tutorial, we will learn to execute Callable tasks …

Java Fixed Size Thread Pool Executor Example

In previous tutorial, we learned about basic thread pool executor with unlimited possible number of threads into the pool and it’s example usage. Now lets look example of fixed size thread pool executor which will help in improved performance and better system resource utilization by limiting the maximum number of …

Java Thread Pools and ThreadPoolExecutor

Why do we need a thread pool in Java? The answer is when we develop a simple, concurrent application in Java, we create some Runnable objects and then create the corresponding Thread objects to execute them. Creating a thread in Java is an expensive operation. And if you start creating …

Tomcat SSL or HTTPS Configuration Example

Secure Socket Layer (SSL) is a secure transfer protocol used for communication on the Internet using cryptographic methods. The main purpose of the SSL protocol is to guarantee that no one can tamper with the communication between a browser and the server where the web application is deployed. Another purpose …

How to run Tomcat on port 80

By default, Tomcat is configured to run on port 8080. That’s why all the deployed web applications are accessible though URLs like http://localhost:8080/yourapp. If you want to run an application on URL like http://localhost/yourapp, then you will need to change the default port 8080 to 80, which is default port …

Tomcat – Architecture and server.xml configuration

We already learnt how webservers work in general when you deploy your web application on server and access from a browser. Now let’s learn the stuffs inside server which may not be used in day to day job, but they will certainly help you when you are configuring your application …

Spring WebMVC Interview Questions

Spring MVC Interview Questions and answers. These have been written to help beginners as well as experienced developers to prepare for their next interview.

Spring AOP Interview Questions

After going through spring core interview questions, let’s cover the top Spring AOP interview questions we may expect in our next technical interview. Again, please feel free to suggest new questions that are not part of this post to include them to benefit a larger audience. 1. Describe Spring AOP? …

Spring Interview Questions with Answers

This page lists the most asked and important Spring framework interview questions that we may face in our next job interview. 1. What is Spring Framework? What are it’s Main Modules? Spring is probably the most used Java framework for developing simple web applications to enterprise-class cloud applications and microservices. …

ConcurrentLinkedDeque Example – Non-blocking Thread-safe List

In java, most used data structure is probably a list. A list has an undetermined number of elements and you can add, read, or remove the element of any position. Additionally, concurrent lists allow the various threads to add or remove elements in the list at a time without producing …

Spring REST JSON Response Example

In this spring rest json example, we will learn to write RESTFul webservices capable of returning JSON for resources using MappingJackson2JsonView.

Produce XML Response with Spring WebMVC Controller

In this Spring REST XML example, I am writing hello world example for REST APIs using Spring REST features. In this example, I will be creating two APIs which will return XML representation of resources. 1. Maven Dependencies Let’s start with runtime dependencies which you will need to write these …

Spring MVC Populate and Validate Dropdown Example

If you are working on any customer facing web application which is developed using Spring MVC, then your will probably need to use dropdown box as well somewhere in application UI. This tutorial will help you in displaying a pre-populated dropdown and then validating whether user selected any value while …

Spring Bean Validation – JSR-303 Annotations

JSR-303 bean validation is an specification whose objective is to standardize the validation of Java beans through annotations. The objective of the JSR-303 standard is to use annotations directly in a Java bean class. JSR 303 specification allows the validation rules to be specified directly into the fields inside any …

Spring MVC Custom Validator Example

In spring mvc form submit tutorial, we learned about displaying displaying a form and submitting form data, including validating inputs using BindingResult.rejectValue(). In this example, we will learn to build a more robust validator for EmployeeVO model object. This validator is custom implementation of Validator interface. In this example, I …

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.