Kensoft PH
  • Blog
    • Java
    • Programming Tips
  • Download
    • KenshotApplication
  • Contact
  • About
Java Quiz
No Result
View All Result
Kensoft PH
  • Blog
    • Java
    • Programming Tips
  • Download
    • KenshotApplication
  • Contact
  • About
Java Quiz
No Result
View All Result
Kensoft PH
No Result
View All Result
Home Java

How to connect Java to MySQL database using Xampp server | 100% best for beginners

October 27, 2020 - Updated on January 23, 2023
in Java
Reading Time: 3 mins read
1
MySQL database using XAMPP
18.3k
VIEWS
Share on FacebookShare on TwitterShare via Email

Connecting our application to a MySQL database using XAMPP is very important to make the data persistent. Your application must have a database like MySQL to store the data from the user or from the application itself.

For example, your application doesn’t have a database, and the user inputs their important information. After closing and reopening the application, you will notice that the data is gone because the application doesn’t have a database. There are so many databases to learn and integrate with your application.

In terms of development with a database, XAMPP is very useful for managing the database in development. XAMPP allows you to manage the Apache server and databases offline using PhpMyAdmin, at your localhost. Using XAMPP, you can connect your Java application to the MySQL database using XAMPP. Connecting your application to the MySQL database using XAMPP is very easy, but before doing that. We need to have XAMPP and MySQL JDBC driver to allow us to connect to the database.

To download the XAMPP application and MySQL JDBC driver, please proceed below.

  • Download XAMPP
  • Download MySQL JDBC driver

Contents

Toggle
  • Installing XAMPP on Windows
  • How to connect Java MySQL database using XAMPP
  • YouTube Video

Installing XAMPP on Windows

Installing XAMPP on Windows is very easy. After you download the application, install it. When the setup is running, click next to proceed to the installation. When you see the “Select Components,” I recommend you select all and click next. If you see “C:\xampp” in the installation folder, you can set the path you want, but it is up to you. Then click on next until the installation process is running.

After the installation, you can run XAMPP and see its control panel. The control panel has modules, and you can start the Apache server and MySQL server to make a database for development. To create a database, click on the admin button inline with MySQL, and you will be redirected to PhpMyAdmin localhost. Suppose you are ready to connect your Java application to the MySQL database using XAMPP. Please proceed below to learn more.

How to connect Java MySQL database using XAMPP

The first step is to create your Java project. Go to Libraries (right-click to add library) under your project below the Source packages in your Java project. Then, add the MySQL JDBC Driver. If you don’t have the library, click on the create button on the right side. Set the Library name and click OK. On the classpath tab, add the jar from the driver you have downloaded.

MySQL database using XAMPP

Navigate to the Services tab and right-click on Database to create a new connection. On the New Connection Wizard window, select the MySQL driver (connector / J driver). MySQL database using XAMPP

 

In Customize connection, enter your database name and test the connection and copy the JDBC URL for later.MySQL database using XAMPP

Code for the connection to the database.

public static void main(String[] args) {
    try{
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection con = DriverManager.getConnection("dbURL","username","password");
        Statement state = con.createStatement();
        System.out.println("connected");
    }catch(Exception e){
        e.printStackTrace();
    }
}

MySQL database using XAMPP

YouTube Video

YouTube video
Previous Post

Java Hover Effect | 100% best for beginners

Next Post

How to use CRUD in Java programming | 100% best for beginners

KENSOFT

KENSOFT

My name is Kent, and KENSOFT represents a combination of my name and my passion for software development. Java is my preferred programming language, and I specialize in developing computer applications using this technology.

Related tutorials

How to Use the JavaFX Pie Chart 100% For Beginners
Java

How to Use the JavaFX Pie Chart 100% For Beginners

June 12, 2024 - Updated on October 6, 2024
212
How to Connect to an API Using JavaFX
Java

How to Connect to an API Using JavaFX

May 26, 2024 - Updated on September 28, 2024
220
JavaFX SQLite Database CRUD Tutorial
Java

JavaFX SQLite Database CRUD Tutorial | Note Application

May 26, 2024 - Updated on September 28, 2024
648
Next Post
crud in java

How to use CRUD in Java programming | 100% best for beginners

Graphical User Interface

100% best Java swing mailing Graphical User Interface (GUI)

send email using java

Java Send Email Tutorial | 100% Best for beginners

Comments 1

  1. Gregorr says:
    4 years ago

    Thank you for sharing. Informative!

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tools

Multi-platform installer builder

Java profiler

  • Trending
  • Comments
  • Latest
MySQL database using XAMPP

How to connect Java to MySQL database using Xampp server | 100% best for beginners

October 27, 2020 - Updated on January 23, 2023
Failed to automatically set up a JavaFX Platform

Failed to automatically set up a JavaFX Platform SOLVED Apache NetBeans 12.3 | Best way

April 11, 2021 - Updated on July 3, 2022
JavaFX 17

How To install JDK 17 and JavaFX 17 on NetBeans IDE | Best

November 15, 2021 - Updated on December 13, 2021
hide and show password in jPasswordField

JPasswordField in Java Hide or Show Password | 100% best for beginners

April 2, 2021 - Updated on September 21, 2022
Failed to automatically set up a JavaFX Platform

Failed to automatically set up a JavaFX Platform SOLVED Apache NetBeans 12.3 | Best way

3DES in Java and AES in Java

How to use AES and 3DES in Java | 100% best for beginners

JavaFX Splash Screen

How to create JavaFX Splash Screen | 100% best for beginners

set up JavaFX and Scene Builder

How to set up JavaFX and Scene Builder in NetBeans IDE | 100% best for beginners

C# vs Java vs Python

C# vs Java vs Python: Which Programming Language to Learn

July 2, 2025
Complete Guide to Freelance Programming in 2025

Complete Guide to Freelance Programming in 2025

July 1, 2025 - Updated on July 3, 2025
Best IntelliJ IDEA Plugins for Developers in 2025

Best IntelliJ IDEA Plugins for Developers in 2025

June 30, 2025
top 10 common coding mistakes beginner make

Top 10 Common Coding Mistakes Beginners Make

June 29, 2025
Facebook Instagram Youtube Github LinkedIn Discord
Kensoft PH

My name is Kent, and KENSOFT represents a combination of my name and my passion for software development. Java is my preferred programming language, and I specialize in developing computer applications using this technology.

Categories

Website

Check the status

Privacy Policy

Terms and Condition

Sitemap

Latest Tutorials

C# vs Java vs Python

C# vs Java vs Python: Which Programming Language to Learn

July 2, 2025
Complete Guide to Freelance Programming in 2025

Complete Guide to Freelance Programming in 2025

July 1, 2025 - Updated on July 3, 2025
Best IntelliJ IDEA Plugins for Developers in 2025

Best IntelliJ IDEA Plugins for Developers in 2025

June 30, 2025

© 2025 Made With Love By KENSOFT PH

No Result
View All Result
  • Blog
    • Java
    • Programming Tips
  • Download
    • Kenshot
  • Contact
  • About
  • Java Quiz

© 2025 Made With Love By KENSOFT PH

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.