Simple Java Application that demonstrates the use of JDBC (Java Database Connectivity) to connect to a MySQL database. The application also includes a graphical user interface (GUI) built using Java Swing.
- Connects to a MySQL database using JDBC
- Supports basic database operations such as adding, removing, and searching for users
- Provides a simple and intuitive interface for interacting with the database
Before running the application, ensure you have the following:
- Empty MySQL database which you will later use to import
jdbc_demo.sql
schema from this repository - The JDBC driver required to connect to MySQL
-
Clone the Repository:
git clone https://github.com/petarmilunovic/jdbc-demo.git cd jdbc-demo
-
Add MySQL Connector/J to your project:
- Download the
mysql-connector-java-8.0.22
library from the MySQL website. - Add the JAR file to your project’s classpath.
- Configure Database Connection:
-
Import the provided database schema
jdbc_demo.sql
into your empty MySQL database. The schema is essential as it contains the specific columns and data types required by the application:mysql -u your-username -p your-empty-database < "absolute_path/to/jdbc_demo.sql"
-
Modify the
connect()
method inDatabase.java
file to use your database’s details and credentials.
- Run the Application:
- Compile and run the application from your IDE.
- Use the GUI to perform CRUD operations on the database.