XAMPP and JavaFX MySQL Configuration Guide
Djuraev Sirojiddin
November 11, 2024
Setting Up XAMPP and MySQL
Step 1: Download and Install XAMPP
• Download XAMPP: Visit https://www.apachefriends.org and
download the latest version of XAMPP for your operating system (Windows,
macOS, or Linux).
• Install XAMPP:
• Run the downloaded installer.
• During installation, select Apache and MySQL (MariaDB) components.
• Continue with the default settings to complete the installation.
2
Step 2: Start XAMPP Services
• Open XAMPP Control Panel:
• On Windows, open the XAMPP Control Panel; on macOS and Linux, open the
XAMPP application.
• Start Apache and MySQL Services:
• In the Control Panel, locate the Apache and MySQL modules.
• Click Start for both Apache and MySQL to initiate web and database servers.
8
Step 3: Open phpMyAdmin to Manage Databases
• Access phpMyAdmin:
• Open a web browser and navigate to http://localhost/phpmyadmin.
• phpMyAdmin is a web-based tool to manage MySQL databases.
11
Step 4: Create a New Database Named books
• Create Database:
• In phpMyAdmin, click on the Databases tab.
• In the Create database field, enter books.
• Click Create to make the books database.
12
Step 5: Verify the Database Creation
• Check Database:
• After creation, the database should appear on the left sidebar in phpMyAdmin.
• Click on books to view its structure and begin adding tables or importing data.
13
Additional Notes
• Now, you can create tables, insert data, and run queries within the books database
using phpMyAdmin or SQL commands in the SQL tab.
• Remember to stop Apache and MySQL services in the XAMPP Control Panel when
done to free up system resources.
14
Configuring JavaFX with MySQL
Step 1: Set Up JavaFX and MySQL Dependencies
Adding Dependencies in pom.xml:
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
</dependencies>
15
Step 2: Configure JavaFX Project Module Dependencies
module-info.java:
module YourProjectName {
requires javafx.graphics;
requires javafx.controls;
requires mysql.connector.java;
requires java.sql;
opens org.example;
}
• Ensure that module-info.java is correctly configured with all required
dependencies.
• If not using modules, skip this step.
16
Step 3: Create Database Connection Utility
DatabaseUtil.java:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DatabaseUtil {
private static final String URL = "jdbc:mysql://localhost:3306/
YOUR_DATABASE";
private static final String USER = "your-username";
private static final String PASSWORD = "your-password";
public static Connection getConnection() throws SQLException {
return DriverManager.getConnection(URL, USER, PASSWORD);
}
}
17
Components Summary
• DatabaseUtil: Manages MySQL connection.
• pom.xml: Specifies JavaFX and MySQL dependencies.
• module-info.java: Configures project modules (if using Java modules).
18
Next Steps
Continue coding with further JavaFX and MySQL integration.
19