0% found this document useful (0 votes)
87 views

Simpledb Demo Java

This document provides a 3 step tutorial for connecting a Java application to a MySQL database: Step 1 explains how to create a database and table in MySQL. Step 2 shows sample Java code to connect to the database, which initially errors because the MySQL driver is not included. Step 3 describes downloading and adding the MySQL connector JAR file to the build path in Eclipse to resolve the error, allowing the Java code to successfully connect to and query the database.

Uploaded by

joshua
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Simpledb Demo Java

This document provides a 3 step tutorial for connecting a Java application to a MySQL database: Step 1 explains how to create a database and table in MySQL. Step 2 shows sample Java code to connect to the database, which initially errors because the MySQL driver is not included. Step 3 describes downloading and adding the MySQL connector JAR file to the build path in Eclipse to resolve the error, allowing the Java code to successfully connect to and query the database.

Uploaded by

joshua
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SIMPLE DATABSE DEMO using Java and MySQL

AUTHOR: CodyScott at phcorner.net


Join “Seriously Java” Group
STEP 1: Let’s create our Database and Table using MYSQL.
(Kung hindi pa familiar sa MYSQL and PHPMYADMIN, maraming tutorial sa youtube on how to install WAMP OR
XAMPP packages)

Ito yung DATABASE (“phpcorner_db”) ko and meron siyang isang TABLE (“students”)

Ito yung STRUCTURE ng “students” table.

Ito yung 2 data na inilagay ko sa “students” table.... pang sample

TAPOS NA TAYO SA DATABASE PART. Ready itong gamitin.


Take note: At this point dapat alam mo na ang database USERNAME, PASSWORD at URL address ng database mo.
SIMPLE DATABSE DEMO using Java and MySQL
AUTHOR: CodyScott at phcorner.net
Join “Seriously Java” Group

STEP 2: Let’s start coding sa JAVA. In this demo, gamit ko ay ECLIPSE.

Ito yung code.

Of course, mag-e-error talaga.


Sinadya ko para ituro ko rin kung paano ayusin. VERY IMPORTANT.
Sabi NO SUITABLE DRIVER FOUND. So let’s add a driver.
SIMPLE DATABSE DEMO using Java and MySQL
AUTHOR: CodyScott at phcorner.net
Join “Seriously Java” Group

In order for Java to connect to MYSQL, it needs a DRIVER made by MySQL specifically to be used by Java Programs.

Punta sa website ng MySQL and look for and download JDBC Driver for MySQL

Choose PLATFORM INDEPENDENT. Download ang save sa computer.


SIMPLE DATABSE DEMO using Java and MySQL
AUTHOR: CodyScott at phcorner.net
Join “Seriously Java” Group

Open the downloaded zip file. And inside the zip file meron isang JAR file or zip file called mysql-connector-java-8.0.12

Right-click and copy


SIMPLE DATABSE DEMO using Java and MySQL
AUTHOR: CodyScott at phcorner.net
Join “Seriously Java” Group
Then go to your eclipse, select project folder, RIGHT-Click and PASTE.

..pagkatapos i-paste, hindi pa yan ready. We need to add it to BUILD PATH.

RIGHT-CLICK mo yung mysql-connector file and BUILD PATH.....ADD TO BUILD PATH

THEN YOU ARE READY TO RUN YOUR JAVA CODE AGAIN


SIMPLE DATABSE DEMO using Java and MySQL
AUTHOR: CodyScott at phcorner.net
Join “Seriously Java” Group
DYARANNNNN!.... Congratulations!

TAKE NOTE: the user and password is not secured and never ever save password in your code.
This is just a demo. In the next series, I wil demo some ways to optimize code and also how to use java beans or objects
to manipulate Database data. How to use them in forms with GUI.

ABANGAN.

Join phcorner.net “SERIOUSLY JAVA” group if you want to learn more cool stuff.

You might also like