15. Appendices
15.1. The MySQL DBMS with Laragon
Chapters 10 and 11 of this document use the MySQL 8 DBMS. The easiest way to install it on Windows is to install Laragon, a portable development environment that includes MySQL, the graphical client HeidiSQL, a configured terminal, Apache, and PHP. The author also uses it for his PHP courses.
15.1.1. Installation
Laragon can be downloaded from https://laragon.org. The installation is standard; you can use the suggested installation folder ([C:\laragon]). Laragon provides MySQL 8 (the exact version depends on the Laragon version), with a [root] administrator account that has no password and a server listening on port 3306 on the local machine. This is the configuration assumed by the examples in the document, where the JDBC URL is of the form:
with the username [root] and an empty password. If MySQL was installed differently, with a password for [root], you must update the examples accordingly ([.properties] files or constants at the top of the programs).
For a system without Laragon, you can also install MySQL Community Server from https://dev.mysql.com/downloads/mysql/, or its open-source derivative, MariaDB. However, the examples have only been tested with MySQL 8: the scripts in Chapter 10 use a collation specific to MySQL 8 ([utf8mb4_0900_ai_ci]), and with MariaDB, it would need to be adapted, as would the JDBC driver (MariaDB provides its own).
15.1.2. Starting and Stopping MySQL
The Laragon main window includes a “Start All” button that starts the servers (Apache and MySQL) and a “Stop” button that stops them. MySQL is not a Windows service that runs at system startup: it only runs when started from Laragon, which prevents it from consuming resources when not in use. The Laragon menu (right-click in the window) also allows you to start only MySQL and to choose its version.
When MySQL is not running, the programs in Chapters 10 and 11 fail with an exception from the JDBC driver indicating that no connection could be established ([CommunicationsException]: “Communications link failure”): this is the first thing to check in case of an error.
15.1.3. The command-line client
Laragon’s Terminal button opens a terminal where Laragon commands are accessible, including the MySQL command-line client ([mysql]). To connect to the server, use:
Then enter the SQL commands, each ending with a semicolon ([show databases;], [use dbarticles;], [select * from articles;]) and [exit] to exit. The client can also run an SQL script, which is what Chapter 10 does to create its databases:
The scripts completely recreate their database each time they are run: you can rerun them to restore the data to its initial state after testing.
15.1.4. The HeidiSQL graphical client
The Laragon Database button launches the graphical client HeidiSQL. Upon first launch, HeidiSQL offers a connection session that is already configured for the Laragon MySQL server (host [127.0.0.1], user [root], blank password, port 3306); simply open it. You will see:
- on the left, the tree view of the server’s databases and their tables;
- on the right, tabs showing a table’s structure, its data (which can be edited directly), and a field for entering SQL queries (the “Query” tab), which are executed by [F9].
To create a database using a script from Chapter 10, open the script (via the “File” menu, using the command to load a file: SQL) in a query tab, then execute it ([F9]). You can also create a database, a user, and user permissions using the menus in HeidiSQL (right-click on the connection / “Create New” / "Database"; "Tools" menu / "User Manager"), but the SQL scripts have the advantage of being reproducible and able to be rerun.
IntelliJ IDEA can also connect to a database via its “Database” window: there you can view the tables and their data, and you can execute SQL queries without leaving the IDE.
15.1.5. Databases in this document
Chapters 10 and 11 use the following databases, all located on the local MySQL server:
Database | Chapter | Creation |
[dbarticles] | 10 | Script [10-jdbc/sql/dbarticles.sql]: Table [articles] from the JDBC examples |
[dbtaxes] | 10 | script [10-jdbc/sql/dbtaxes.sql]: the [brackets] table from version 6 of the [Tax] application and the [admtaxes] user |
[hbfirst], [hbarticles], [hbshop], [hbclients], [hbconcurrency] | 11 | created by the programs themselves (option [createDatabaseIfNotExist=true] of the JDBC URL; tables created by Hibernate or by versioned scripts) |
[hbtaxes] | 11 | created and populated by the [CreateDatabase.kt] program in version 7 of the [Tax] application |
Once testing is complete, a database can be deleted using the SQL command [drop database name;], in the [mysql] client or in HeidiSQL.
15.2. Dependencies Used by Gradle Projects
The following table summarizes the libraries declared by the Gradle projects in the document ([build.gradle.kts] files), along with their versions. They are automatically downloaded from Maven Central by Gradle (or by IntelliJ IDEA) during the first build of a project, along with the libraries on which they depend: Internet access is therefore required at that time.
Library (group:artifact) | Version | Chapters |
[org.jetbrains.kotlin:kotlin-stdlib], [kotlin-reflect], [kotlin-test] (added or versioned by the Kotlin plugin) | 2.4.20 | all ([kotlin-test]: 6, 10; [kotlin-reflect]: 13) |
[org.jetbrains.kotlinx:kotlinx-coroutines-core] (coroutines) | 1.11.0 | 9, 10, 11, 12 |
[tools.jackson.core:jackson-databind] (Jackson 3) | 3.1.5 | 5, 6, 12, 13 |
[org.junit:junit-bom], [org.junit.jupiter:junit-jupiter] (JUnit 6) | 6.0.3 | 6, 10 |
[org.springframework:spring-context] (Spring Framework) | 7.0.9 | 6, 10, 11, 12, 13 |
[org.springframework:spring-orm] | 7.0.9 | 11 |
[com.mysql:mysql-connector-j] (MySQL JDBC driver) | 9.7.0 | 10, 11 |
[com.zaxxer:HikariCP] (connection pool) | 7.0.2 | 10, 11 |
[ch.qos.logback:logback-classic] (logging) | 1.5.38 | 10, 11 |
[org.hibernate.orm:hibernate-core] (Hibernate ORM) | 7.4.5.Final | 11 |
[org.eclipse.angus:angus-mail] (Jakarta Mail) | 2.0.3 | 12 |
[org.springframework.boot:spring-boot-starter-webmvc] (Spring Boot, version determined by its naming convention) | 4.1.1 | 13 |
The Gradle plugins used are [org.jetbrains.kotlin.jvm] ([kotlin("jvm")]), [org.jetbrains.kotlin.plugin.spring], and [org.jetbrains.kotlin.plugin.jpa] / [org.jetbrains.kotlin.plugin.allopen] (compiler plugins for Spring and Hibernate), all version 2.4.20, the Gradle plugin [application] ([gradlew run]), the plugin [org.springframework.boot] 4.1.1 ([gradlew bootRun]) and, in the [settings.gradle.kts] file for each build, the [org.gradle.toolchains.foojay-resolver-convention] 1.0.0 plugin, which downloads JDK 25 if it is not installed (Chapter 2). The wrapper for each project uses Gradle 9.8.0. The projects for the [Tax] application in Chapters 10 through 13 also depend on the subprojects [examples.tax:tax-dao], [tax-business], and [tax-ui] (version 5.0) from Chapter 6: thanks to the composite build ([includeBuild("../06-architectures")]), Gradle builds them itself from their source code, without the need to publish them beforehand.