Month: June 2020

  • How to use Records in Java

    Java 14 came up with a new feature called Records to reduce boiler plate code. One criticism against Java is that it takes too much code to achieve something compared to other languages like Python. The recent features in Java have been primarily targeted to reduce its verbosity. Records are one such feature. Usually when…

  • How to write recursive queries in SQL?

    Let’s say you want to find out all the subordinates to a manager recursively. That is say Kiran reports to Guru and Gayathri reports to Kiran , then the subordinates of Guru are both Kiran and Gayathri. This can be done using recursive queries. Let’s see how to do it in PostgreSQL. This is supported…

  • How to do user authentication in Spring Boot using PostgreSQL database?

    Let’s say you want to create an application in Spring Boot and authenticate the users who use it against credentials stored in a PostgreSQL database. Below are the high level steps to implement it in Spring Boot: Create a spring boot project with authentication related dependencies. Add the database configuration in application.properties against which you…

  • How to convert a Java standalone application into a jar file through command line?

    Let’s say you created a standalone java application and you want to execute it as a jar file. You want to run the main method of a particular class in your application when the jar file is executed. This post explains the steps to convert a java application to a jar file using command line.…

  • Future vs Completable Future in Java

    The best way to run asynchronous threads in Java had been to use the Executor Service framework until Java 8. Executor Service returns a Future object which can be used to retrieve the result of an asynchronous thread. But it comes with few drawbacks. Among the many features introduced in Java 8 , one of…

  • HTTP Client – Java 11 – Making HTTP requests in Java is so easy now

    Until Java 11 , making HTTP requests was not intuitive . You had to use the non friendly URLConnection class. With Java 11 , it looks easier and cool. To make any HTTP request ,you need the following: A HTTP Request A HTTP response A HTTP client to send the request and get the response…