In this tutorial, we explain how to load, modify and finally save some YAML data. We use the SnakeYAML library to achieve this. YAML is a data-serialization language, that allows engineers to share data as readable text files easily. YAML is a JSON superset and has a very light human-friendly syntax. The YAML data format […]
Category: Java
We explain how to build a Java Spring Boot application with JSP, API and static file endpoints. Then we run the application locally and test the endpoints with cURL, to check that they respond correctly. All that in less than 5 minutes. 1) The JSP controller Let’s say we have a JSP file hello.jsp in […]
In this article, we will explain how to use and debug HikariCP Pool for JDBC SQL with Logback. The goal is to be able to monitor how many connections are opened / closed by the connection pool. We will do a multi-thread load test of SQL requests on the pool, and see how it reacts. […]
In this tutorial, we will see how JDBC Java transactions rollbacks are useful, with a real world example and a full Java demo. We will look at the particular case of batch inserts. 1) Batch inserts without rollback Let’s use the following SQL table: Starting from a JDBC connection object called conn: , the batch […]
In this tutorial, we will see how to batch SQL insert queries, using Java JDBC. Then, we will do a performance test to compare batched inserts VS non-batched inserts. 1) The SQL table We will use the following table: 2) Batch inserts Starting from a JDBC connection object called conn: simply do: We use the […]
In this quick tutorial, we will explain how to download an image directly with Selenium in Java. The advantage of this method, instead of using a classic HTTP client like CURL, is that the website will behave exactly the same way as if you were browsing it with a classic browser like Chrome. 1) Setup […]
In this quick tutorial, we will see how to scroll slowly to the bottom of a web page, using Puppeteer Java and Playwright. Playwright is a new browser automation framework developed by Microsoft. It is based on JavaScript Puppeteer. Look here for a quick tutorial on how to use Playwright in Java. 1) Compute the […]
In this short tutorial, we will see how to do browser automation with a Java equivalent of JavaScript Puppeteer: a new framework developed by Microsoft called Playwright. 1) Import the dependency in your pom.xml In your pom.xml file, add: <dependency> <groupId>com.microsoft.playwright</groupId> <artifactId>playwright</artifactId> <version>1.15.2</version> </dependency> 2) Open Firefox and navigate to Wikipedia.com To open a Firefox […]
In this short tutorial, we will see how to easily run a private docker image using Java TestContainers. We will use a private AWS ECR registry, but the code will work the same with any other private registry. 1) Needed parameters First, you need to gather the following parameters: String registry = “601730646169.dkr.ecr.us-west-2.amazonaws.com”; String image […]
How to pretty print a database SQL schema (table names, columns names and types), in Java using JDBC. Starting from a JDBC connection object to your database called conn: java.sql.Connection conn; simply do: The console output is the following: client ——————————————————————– id : uuid name : varchar product ——————————————————————– id : uuid name : varchar […]