Introduction Here I am going to tell you how to insert and update a list of objects in batch using JDBC PreparedStatement in Java programming language. Generally when you have a list of objects or lots of data then probably it is not a good idea to insert or update individual record or object into…

Posted in Java

Batch insert and batch update into DataBase using JDBC PreparedStatement

Introduction In an excel file, you might have seen there are comments on text cells or columns. So in this tutorial you will see how to add or insert comments in excel sheet cell using Apache POI Java API. Comments can help you to remember what all are formulae or instructions you want to provide…

Posted in Excel Java

How To Add Comments In Excel Sheet Cell Using Apache POI Java API

Here in this tutorial we will discuss whether we should synchronize the run() method or not. Another question may arise can we synchronize run() method? In simple word, yes, we can synchronize the run() method. Do we need to synchronize the run method? When it comes to whether we need to synchronize or not, then…

Posted in Java

Should we synchronize run() method?

Here we will discuss on how to post tweets using Twitter4j Java API. Twitter4j is an unofficial Java library and using this you can easily integrate Java application with Twitter service. You can easily use standalone jar for this twitter4j API or using maven or gradle build tool to download the required jar on the…

Posted in Java Twitter4j

How to post tweets using Twitter4j Java API

Here I am showing a simple example on what is callback method in Java. A callback is a piece of code that you can pass as an argument to be executed on some other code. Since Java doesn’t yet support function pointer, the callback methods are implemented as command objects. A callback will usually hold…

Posted in Java

Callback method example in Java

Introduction In this example I am going to show you how to work with filters in excel file on text column using Java and Apache POI library. The following list of custom filters for number columns can be implemented: Equals Does Not Equal Greater Than Greater Than Or Equal To Less Than Less Than Or…

Posted in Excel Java

Excel Custom Filters on Number Column using Java and Apache POI

Introduction In this example I am going to show you how to work with filters in excel file on text column using Java and Apache POI library. The following list of custom filters for text columns can be implemented: Equals Does Not Equal Begins With Ends With Contains Does Not Contain

Posted in Excel Java

Excel Custom Filters on Text Column using Java and Apache POI

Java 8 Date In this tutorial I am going to show you how to add days, weeks, months, years to a particular date in Java 8 or later. Similarly I will also show how to substract days, weeks, months, years from a particular date. The date is actually LocalDate API in Java 8 or later….

Posted in Java

Add Or Subtract Days Weeks Months Years On Java 8 Date

Introduction In this tutorial I am going to show you how to create PDF file content with different formats using Java programming language. In this tutorial I am going to use iText library to generate the PDF document. Many applications require dynamic generation of PDF documents. The applications, where dynamically generated PDF is required, are…

Posted in Java

How to create PDF File Content using Java

Introduction In this tutorial I will show you how to read CSV file using Java 7 or later versions. I will use here Java’s new feature Path API. I will also use Java 8’s Stream API to split the comma separated line and map the record into String array. I am going to show you…

Posted in Java

How To Read CSV File Using Java

What is busy waiting or spinning? Busy spinning or waiting in multi-threading environment is a technique in which a process repeatedly checks if a particular condition is true instead of wait() or sleep() method and without releasing the CPU. In other words busy spinning is one of the techniques to wait for events without releasing…

Posted in Java

Busy Waiting or Spinning Example in Java Multi-threading

We will discuss about how to exchange data between two threads or a pair of threads. The Exchanger class under java.util.concurrent package was introduced in JDK 1.5 along with CyclicBarrier, CountDownLatch to exchange data between two threads only. A synchronization point at which two threads can pair and exchange data within pair using the exchange()…

Posted in Java

How to exchange data between two threads using Exchanger in Java