Configure c3p0 with Hibernate and Spring
Learn to configure C3P0 connection pooling with Hibernate 6. Learn how to enforce c3p0 over other connection polls and debug connection leaks.
Learn to configure C3P0 connection pooling with Hibernate 6. Learn how to enforce c3p0 over other connection polls and debug connection leaks.
Learn to connect to an in-memory database (such as H2 or Hsqldb) from the JUnit 5 unit tests. This will help in writing tests that do not depend on a live database connection.
Learn to bootstrap SessionFactory with StandardServiceRegistryBuilder, StandardServiceRegistry and Metadata in Hibernate versions 5 and 6.
Whenever we execute a Java program, a separate memory area is reserved for storing various parts of our application code which we roughly call JVM memory. Though not necessary, having some knowledge about the structuring of this memory area is quite beneficial. Knowing Java memory model becomes more important when …
Learn how to read CSV file and write data to CSV file in Java. We will use opencsv library which provide excellent support to work with CSV files in Java.
In HiLo game, we have to adjust our next guess such that we are able to guess the right number within six attempts. Learn with a Java program.
For reading a file line by line, the LineNumberReader class could be used that allows to keep track of which line we are currently processing.
Learn to read property file in java using Properties.load() method. Then we will use Properties.setProperty() method to write a new property into file,
Learn to read the user input from the console in Java and write to the console using Console, BufferedReader and Scanner with examples.
Java FileFilter accepts File objects and thus can be used to filter the files based on other attributes such as read-only, directory etc.
Learn to read or parse XML documents into String, write to files and convert to POJO using Java DOM parser API with examples.
Both DOM and SAX parsers are extensively used to read and parse XML files in java applications and both of them have their own set of advantages and disadvantages.
In this iText tutorial, we are writing various code examples to read a PDF file and write a PDF file. iText library helps in dynamically generating the .pdf files from Java applications. The given code examples are categorized into multiple sections based on the functionality they achieve. With each example, …
Most of the applications today, which are targeted at a larger audience e.g. internet users, usually deal in money as well. In such applications, a requirement will be to display money/currency in a format specific to that location or country. In this tutorial, I am giving some examples that will …
Learn to get the locale of the user in Java that is used to format the content according to the user’s demographics (geographical, political, or cultural information). 1. What is Locale? Suppose we are developing an application and we are asked to make the application customized for international end-users. To …
Deserialization in Java is the process by which the object previously serialized is reconstructed back into its original form i.e. object instance.
Many times we come to a situation where we need to modify the server configuration such that it is specific to an application. And if we got more than one such application and we want each application to have its own defined configuration options, then it needs some sort of …
Learn about Java Generics PECS which is related to producing and consuming collections with easy-to-follow examples.
In previous tutorials, We have learned about MongoDB basics and installing MongoDB in Windows, as well as we learned about Inserting documents in MongoDB and selecting documents from MongoDB. In this tutorial, I am giving few examples of code which will help you when you have to work with images …
Learn the main differences between tags <context:annotation-config> and <context:component-scan> in Spring MVC applications so that when we use them in the future, we will know, what exactly we are doing. 1. The Differences between <context:annotation-config> vs <context:component-scan> The first big difference between both tags is that <context:annotation-config> is used to …
In this article, I am listing 5 simple steps to learn Java, and by following these steps, you can become a good Java programmer over time.
Learn the difference between method overloading and method overriding in java, which mainly involve method name, signature, parameters list and return type.
The Java transient keyword is used on class attributes/variables to indicate that serialization process of such class should ignore such variables while creating a persistent byte stream for any instance of that class. A transient variable is a variable that can not be serialized. According to Java Language Specification [jls-8.3.1.3] …
In computer architecture, 64-bit computing is the use of processors that have datapath widths, integer size, and memory addresses widths of 64 bits (eight octets/bytes). Also, 64-bit CPU and ALU architectures are those that are based on registers, address buses, or data buses of that size. From the software perspective, …
Java Generics is a technical term denoting a set of language features related to the definition and use of generic types and methods.
Learn to convert JSON to Map and convert a Map to JSON string using Jackson 2. Given example uses Jackson ObjectMapper for conversions.
If you are working on Jackson library and trying to marshal/unmarshal Java objects to/from JSON documents, you may encounter JsonMappingException error. 1. JsonMappingException When we are parsing a JSON file into Java object or we are converting the Java object to JSON representation, we must have created a POJO class. …
One of the best additions in java 5 was Atomic operations supported in classes such as AtomicInteger, AtomicLong etc. These classes help you in minimizing the need of complex (un-necessary) multi-threading code for some basic operations such as increment or decrement a value which is shared among multiple threads. These …
Reflection is one of those things like multi-threading where everyone with experience of it says “Don’t use it unless you absolutely have to”. Above quote is absolutely true for all for us alike. In my previous tutorial, I discussed basics of annotation in which I discussed the usage of reflection …
An annotation is a kind of metadata in Java that can be applied to various elements of Java source code so that later some tool, debugger, or application program can take advantage of these annotations; and help analyze the program in a positive and constructive way. Just to mention, we …
All of us must have encountered NullPointerException in our applications. It happens when you try to use an object that has not been initialized, initialized with null or does not point to any instance. In simple words, NULL simply means ‘absence of a value’. In this Java tutorial, we will …
At entry level Java programmer, you can expect this interview question on Hashtable vs HashMap. Though the question becomes really easy when you know other concepts like how hashmap works, yet after getting a many queries from my blog readers who are preparing for or working at junior level, I …
ASCII (American Standard Code for Information Interchange) is a character encoding standard that assigns numerical values to characters. Each character is represented by a unique numerical value ranging from 0 to 127. Similarly, Hexadecimal (or hex) is a base-16 numbering system that uses 16 distinct symbols: 0-9 and A-F (or …
Multi-threading is very popular topic among interviewers from long time. Though I personally feel that very few of us get real chance to work on a complex multi-threaded application (I got only one chance in last 7 years), still it helps in having the concepts handy to boost your confidence …
In MongoDB learning series, we have already covered the MongoDB basics, MongoDB installation in Windows, and how to query/select documents from a collection. In this tutorial, I am listing multiple ways you can utilize to insert or add document(s) into a collection in MongoDB. 1. Sample Document to Insert into …
Defining thread safety is surprisingly tricky. A quick Google search turns up numerous “definitions” like these: Thread-safe code is code that will work even if many Threads are executing it simultaneously. A piece of code is thread-safe if it only manipulates shared data structures in a manner that guarantees safe …
Learn to split a String with delimiters in Java using String.split(), StringUtils.split() and Splitter.split() APIs with examples.
MongoDB find document examples. Learn number of ways to find a document or multiple documents based on same condition as we do in SQL using WHERE CLAUSE.
Java fork-Join breaks the task at hand into subtasks until the subtasks are simple enough that they can be solved without further breakups.
The “java.exe” and “javaw.exe” are Java executables on the Windows platform used to launch the GUI and Text-based Java programs.
Learn to install MongoDB on Windows machines, starting and shutting down the database, and verify the installation and database connection.
Before jumping directly into basics of MongoDB, we should try to understand the need to No-SQL database itself. Why the traditional relational databases are loosing the battle with their new competitor like MongoDB. Why they are so popular now-a-days. Why? Why NoSQL? Interactive applications have changed dramatically over the last …
Java program to calculate age from date of birth using Java 8 localdate, period class, joda library and Java date, calendar classes.
To increase Console Output Limit in Eclipse, we can increase the limit of log statements in console OR simply remove the limit altogether.
1. Introduction In BlockingQueue and ThreadPoolExecutor example, we learned creating a CustomThreadPoolExecutor which had the following capabilities: Tasks are being submitted to the blocking queue. An executor picks up the task from the queue and execute them. It had overridden beforeExecute() and afterExecute() methods to perform pre-and-post activities if needed. …
Create custom templates for common usecase and then effortlessly use a shortcut for it whenever we need to write that piece of code.
Learn to use classes from Java IO, New IO and Commons IO to delete a directory including all the subdirectories and files in it.
Learn to fix the ContextLoaderListener class not found error that is present used in a web application and is part of the spring-web module.
If you are working on a web application and you define the taglibs in your web.xml file then you may encounter this exception. The exception trace in server console looks like this when you start up the server. Solution You just need to confirm the allowed tags by web.xml confirming …
The adapter design pattern is a structural design pattern used to allow two unrelated interfaces to work together. The object that joins these unrelated interfaces is called an Adapter. The definition of Adapter provided in the original Gang of Four book on Design Patterns states: “Convert the interface of a …
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.