Support Java Optional in Hibernate 6 entity, thanks to the Lib Custom library, a wrapper that simplifies calls to Byte Buddy library In this tuto we use the functional option class: OptionF, but with little changes you can use any other option class, such as Optional 1) Add lib-custom to your pom.xml dependencies Lib-custom is […]
Category: SQL
In this tutorial, we will backup an AWS RDS MySQL database as a dump, then we will mount the dump locally using a MySQL Testcontainers. Finally, we will explore the local backup content and schema, using SQuirreL. 1) Backup the AWS MySQL database We need an EC2 instance that has access to the database. For […]
How to use the MySQL client command line interface with a private AWS RDS MySQL database. Let’s suppose we already have an EC2 instance, with an app that communicates with the database. For instance, the EC2 instance could be part of an Elastic Beanstalk environment (please see here how to setup a private AWS RDS […]
In this article, we explain how to connect to a decoupled AWS RDS MySQL database from an AWS Elastic Beanstalk Docker environment. We will add the RDS security group to the Elastic Beanstalk environment. 1) Create the AWS RDS database Log into the AWS console, got to the RDS section, and click on the orange […]
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 […]
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 […]
In this tutorial we will see how to create an index on a SQL table column with JDBC, then we will fill a table with 10⁷ rows (using PostgreSQL fast COPY function), and finally we will compare the select performance with vs without the index. 1) The SQL tables and the index We will create […]
In this tutorial we will run a full demo of a real life useful Inner Join, with Java JDBC and PostgreSQL. Let’s consider a recurring business that has Customers, Products to sell to customers and Subscriptions that give the list of products each customer has subscribed to. What we want to do is store all […]