Java Database Connectivity with MySQL | eclipse IDE | phpmyadmin | Advanced Java Programming

To connect Java application with the MySQL database, we need to follow below following steps.

In this example we are using phpmyadmin as the database. So we need to know following informations for the mysql database:

1) Driver class: The driver class for the mysql database is com.mysql.jdbc.Driver.

2) Connection URL: The connection URL for the mysql database is jdbc:mysql://localhost:3306/GSSSKHOKHAR where jdbc is the API, mysql is the database, localhost is the server name on which mysql is running, we may also use IP address, 3306 is the port number and GSSSKHOKHAR is the database name. 

3) Username: The default username for the mysql database is root.

4) Password: It is the password given by the user at the time of installing the mysql database. In this example, we are going to use root as the password.

Let's first create a table in the mysql database, Table name : Students




LoginSystem.java



To connect java application with the mysql database, mysqlconnector.jar file is required to be loaded.

download the jar file mysql-connector.jar


Two ways to load the jar file:
1) Paste the mysqlconnector.jar file in jre/lib/ext folder
2) Set classpath










Output : Login Screen


Output : Wrong Authentication - Login Screen


Output : Successfully - Login Screen

1 comment:

  1. That’s interesting! I didn’t realize advanced Java programming could handle database transactions this efficiently. I’ve been experimenting with JDBC and MySQL, and it really helps to see real-world projects. Anyone tried linking phpMyAdmin directly for testing queries? Also, not related but I recently optimized my setup using roblox fps unlocker and noticed how similar small tweaks can improve overall performance.

    ReplyDelete