Home » Core Java

Core Java

Java 9 Default Garbage Collector Tutorial

1. Introduction This tutorial will introduce us to the new default garbage collector implementation for Java 9, the G1 garbage collector. The G1 garbage collector presents a brand new approach to heap layout and semantic behavior. Optimized for large heaps and tailored to address ever increasing demands of low latency and overall throughput, it provides an excellent opportunity to meet ...

Read More »

Read JSON From a URL Example Using Data Pipeline

I have a problem. I want to read JSON from a URL. Naturally, like anybody else, I googled for some solutions. There were a lot of solutions shared in Stack Overflow and other sites. I tried some of them but I’d like to share the one where I used the Data Pipeline Java library. 1. Tools and Prerequisites Data Pipeline ...

Read More »

Java JDBC MSSQL Connection Example

Java Database Connectivity (JDBC) is a Java-based data access technology that defines how a client may access a database. It provides methods for querying and updating the data in a database. The JDBC classes are contained in the Java package i.e. java.sql and javax.sql. 1. Introduction In this article, we will describe how to write the application code to establish ...

Read More »

Apache Ant Tutorial for Beginners

1. Introduction This tutorial explains why Ant was created and its’ advantages over other build tools. This tutorial also covers the installation of Ant and what goes into an Ant project. In this tutorial, a sample project is set up. The Ant build file, for the sample project, is explored along with a discussion of how Ant is used to ...

Read More »

Java 9 HttpClient Example

1. Introduction This example demonstrates the usage of the new Java Http Client bundled with JDK 9. It is bundled as an incubator module in JDK 9 and implements HTTP/2 and WebSocket with backward compatibility still facilitating HTTP/1.1. It provides synchronous and asynchronous API’s and facilitates HTTP/2 over TLS (upgraded from SSL) when supported. The examples will be demonstrated via ...

Read More »

JDBC Query Builder Tutorial

Handling SQL within a Java application can be tricky. For one thing, Java does not support multi-line string constants, so developers can end up with code that looks like this:                   Sample Code String sql_query = "select *" + "from user_table" + "where name like 'Fred%'"; This code is not just ugly ...

Read More »

JDBC Nested Transactions Example

A nested transaction is used to provide a transactional guarantee for a subset of operations performed within the scope of a larger transaction. Doing this allows us to commit and abort the subset of operations independently of the larger transaction. This operation is theoretically possible, however, in JDBC 3.0 we can’t achieve this as easily as the definition looks. In ...

Read More »

JDBC with Oracle Thin Driver Example

Java Database Connectivity (JDBC) is a Java-based data access technology that defines how a client may access a database. It provides methods for querying and updating the data in a database. The JDBC classes are contained in the Java package i.e. java.sql and javax.sql. 1. Introduction In this JDBC Oracle connectivity example, we will see how to setup a JDBC ...

Read More »

JDBC ResultSetExtractor Example

Spring provides a simplification in handling database access with the Spring JDBC Template. The org.springframework.jdbc.core.ResultSetExtractor interface is a callback interface used by JdbcTemplate’s query methods. Implementations of this interface perform the actual work of extracting results from an SQL ResultSet object. In this article, we will try to show how the ResultSetExtractor mechanism can be applied to a Java application. 1. ...

Read More »

Logging System.out.println Results in a Log File Example

In Java the three main streams stdin (Standard Input), stdout (Standard Output), and stderr (Standard Output Error) are handled by default by System.in, Sytem.out, and System.err respectively. In this example, we will try to show how to redirect the System.out.println() to a log file using Log4j logging services. 1. Introduction Printing messages to the console is an integral part of ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns