LAB ACTIVITY 4A
DATABASE SETUP
DATABASE SETUP
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 4A - DATABASE SETUP
Activity Outcome: Student knows how to make connection to MySQL database in Java program.
CREATING A DATABASE
Create a database Restaurant and table Menu using MySQL with data as shown in Appendix B
CONECTING THE MySQL CONNECTOR
i. To use the MySQL JDBC driver to access databases in Java, you must first download the driver from https://dev.mysql.com/downloads/connector/j/ (JDBC Driver for MySQL (Connector/J)). Choose platform independence in select operating system. (Figure 2.0)
ii. Extract the zip file to a folder and click the folder. You’ll see file ‘mysql-connector-java-8.0.16.jar’ which is the library file that we want.
CREATE PROJECT AND CONNECT MYSQL
Open your Net Bean program. Create new project > Java with Ant> Java Application > Next
2. To import your MySQL connector, in your projects window right-click Libraries > Add JAR/Folder > find your ‘mysql-connector-java-8.0.16.jar’ file > Open
3. Now in your Libraries folder you can see the imported ‘mysql-connector-java-8.0.16.jar’ file
JDBC CONNECTION CODING
Create a new Lab Activity called LabActivity4A
Write a simple connection coding as below. Run and see the output
3. Watch the video for full coding and steps
Link Video : Database Part 1