Categories
AWS Java SQL

Backup AWS MySQL, mount the backup locally and explore with SQuirreL

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 […]

Categories
AWS Docker Java

AWS Elastic Beanstalk with Java Spring Boot, Hibernate and RDS MySQL

In this tutorial, we explain how to build a docker image that contains a Java Spring Boot REST API and JPA Hibernate ORM, to connect to an AWS RDS MySQL database. 1) Get started You can use our previous tutorial that explains how to use Spring Boot with Hibernate. The only things we will add […]

Categories
Java

Minimal, fully running Spring Boot REST API with Java Hibernate and MySQL

In this tutorial, we explain how to run a minimal Spring Boot CRUD REST application, with Hibernate ORM and a MySQL database. We also write unit tests, to check the CRUD operations with the API. We do all this in less than 200 lines of code. This tutorial is useful to get started for any […]

Categories
Java

Dynamic database connection properties for Spring Boot

How to set Spring Boot database connection properties dynamically, in the application main. Also we explain the priority order between static and dynamic properties. 1) The usual static way Usually, Spring Boot properties are set in the application properties file, which has following path: src/main/resources/application.properties and following content: 2) The dynamic programmatic way It is […]

Categories
Bash Java

Public and private PGP keys with Java BouncyCastle, in PEM format

We explain how to generate public and private PGP keys, in Java, using the BouncyCastle library. Then, we store the keys in PEM base64 files, and add the keys to our GPG keyring. Finally, we test the keys by encrypting and decrypting a text file using the Linux gpg command line interface (CLI). 1) BouncyCastle […]

Categories
GCP Java

Google search console Java API, with OAuth code flow or Service Account

In this tutorial, we explain how to connect and use the Google search console Java API. We first connect to the API using either the OAuth authorization code flow, or a GCP Service Account. In particular, we describe how to save a StoredCredential on disk, and how to get a refresh token by setting accessType […]

Categories
AWS Java

Fast delete all the objects in a S3 bucket with Java AWS SDK

In this article, we explain how to fast delete all the objects in a given AWS S3 bucket. We will use batch deletes with the Java AWS SDK. 1) Java AWS SDK dependency First, we need to add the Java AWS dependency to our pom.xml: 2) Gather all the S3 objects keys in the bucket […]

Categories
Java

Read all image metadata with Java

How to read all the metadata of an image (image format, width and height) in Java. We will the use the awesome metadata-extractor library. 1) Add the dependency Add the following dependency to your pom.xml: 2) Read the image metadata For this example, we will use an image from our own website, eazytutorial.com, but you […]

Categories
Java

Modify a YAML file with Java

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 […]

Categories
AWS Bash Linux SQL

Connect MySQL client with private AWS RDS database, from EC2 instance

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 […]