LAB ACTIVITY 4C
Manipulates JDBC connectivity.
Manipulates JDBC connectivity.
Learning Outcomes
By the end of this lab, students should be able to :
Arranges JDBC for database connectivity by applying the appropriate steps.
Hardware/ Software : Personal Computer, Java Development Kit version X.x.x., NetBeans IDE 12.0
LAB ACTIVITY 4C
Activity Outcome: Student know how to use JDBC
First, we will create a simple Swing interface from Lab Activity 2B. Here’s the basic Java Swing code for the interface:
1. Set Up the Database
Create the Database in MySQL: Open MySQL and create a database for storing student information.
Create the Table: You need to create a table to store the student data. Here's an SQL script to create a table named students:
2. Set Up the Java Project
Include JDBC Driver: Ensure that you have added the MySQL JDBC Driver (mysql-connector-java.jar) to your project’s classpath. If using NetBeans or Eclipse, you can add the library through the project properties.
3. Establish the JDBC Connection
Create a class for managing the database connection:
4. Implement the ADD Button
Add a listener for the "ADD" button, and insert the form data into the database.
5. Implement the CLEAR Button
The "CLEAR" button should reset all input fields.
6. Implement the DISPLAY Button
To display the records, retrieve the data from the database.
7. Implement the UPDATE Button
For updating a record based on IC_NUMBER, get the updated values and update the corresponding record.
8. Implement the DELETE Button
The "DELETE" button should remove a record based on IC_NUMBER.
9 :Observe your output.