JDBC Tutorial for Beginners #2 : Connecting Java Program to MySQL Database

JDBC Tutorial for Beginners #2 : Connecting Java Program to MySQL Database



In this video, I have shown how to connect our Java program with an existing database in mysql. The URL structure of mysql is also explained. At the end of the video, a successful connection is made to the database from the program.

This tutorial series covers following topics
■ Connecting Java Program to MySQL Database
■ Inserting data into database
■ Fetching data from database
■ Updating an entry in database
■ Creating a table programmatically
■ Using PreparedStatements
■ Display database contents in JTable

– Genuine Coder

source

Java JDBC Tutorial – Part 1: Connect to MySQL database with Java

Java JDBC Tutorial – Part 1: Connect to MySQL database with Java



5 FREE JAVA VIDEO COURSES – CLICK HERE –

View more videos on my “Java JDBC Tutorial” Playlist:

Closed-Captioning and English subtitles available.

In this tutorial, you will learn how to connect to a MySQL database with Java.

Download source code from

Please subscribe to my channel.

—-

Follow luv2code:

Website:
YouTube:
Twitter:
Facebook:

Join my mailing list: Get advance notice on new tutorials. Emails about 1 per week.

Questions or problems? Post them in the comments section below.

Want to suggest a video? Leave a comment below. I’m always looking for new video ideas.

Let me know what video you’d like for me to create.

Video Transcript
Time – 00:00
Hello. In this tutorial, you will learn how to connect to a MySQL database with Java. In this session we’re going to learn how to connect a MySQL database with Java. Before we get started there are some prep work that needs to take place. One is that you need to have a MySQL database already installed. If not, you can download one from the site listed here on the slide.

Time – 00:20
Next, we’ll need to download and install a MySQL JDBC driver. This driver will allow the Java program to connect to the database. You can download it from this URL, and I’ll do that now. I’ll just take this URL, drop it into my favorite browser and here I am at the page. I’m on this page, this is for downloading the Connector/J browser. I’ll select the platform, platform independent. Now move down and I’ll select download and it will download a zip archive. Make sure you download the most recent version. In this case it’s 5.1.29. Make sure you download something at that version or later.

Time – 01:04
Download, scroll down, select, “No thanks, just start my download.” This will start downloading the file for you. Now what we can do is show it in the finder. I’ll double click it to extract it. At this point I have the driver extracted. There’s a file in here called MySQL connector.jar that we’ll use later.

Time – 01:34
Next, what I need to do is create a Java project in Eclipse. Let’s do that. On Eclipse I’ll say I’ll save file, new, Java project. This will be JDBC demo and I will select finish. What I’ll do is I will add a new class. New, class, this will be my driver and it will have a public static void main region. At this point we have a shell for our project created.

Time – 02:28
Next, what we’ll do is we will talk to the actual development process and I really like this slide because it outlines exactly what we need to do. The first thing we’ll do is add the database driver to the classpath. Next, we’ll get a connection, we’ll submit a SQL query and then we’ll process the result set.

Time – 02:48
Let’s start with step one, adding a MySQL database driver to the classpath. In our Eclipse project I’m going to add a new folder called lib, lib for library. In this lib folder I’m going to add the driver that I downloaded earlier. What I’ll do is I’ll just grab this driver. It’s the MySQL connector bin.jar and I’ll just drag and drop it to this lib folder. It will prompt me and I’ll say go ahead and copy the file.

Time – 03:25
Next, I need to add the jar file, the driver to the classpath. I’ve set this up with properties, choose Java build path and then I’ll choose add jars. Expand this folder, that lib, I’ll grab that jar file and I’ll have it setup. Great.

Time – 03:51
Now we can start coding. We need to get a connection, submit a SQL query and process a result set. Let me just sketch this out on a slide over here. The first thing I’ll do up top is I’ll just do an import on java.sql.* because all of the classes and interfaces that we need are in this package.

Time – 04:17
I’ll also just setup a try catch block just to handle for any exception that may occur. Small typo there.

Time – 04:40
Inside of this section I’m going to first get a connection to database. Then next I will create a statement. Then from here I will execute a SQL query and then I will process the result set.
Time – 05:16
That’s my basic game plan, let’s fill it in with some real code. Here I’ll say connection, myConn = DriverManager.getConnection. I’ll give the jdbc:mysql://localhost:3306/demo student, student. Student is the user ID and student is also the password.

[snip] Click the Transcripts tab for full transcript.

source

JAVA – How To Create Login And Register Form With MySQL DataBase In Java Netbeans

JAVA – How To Create Login And Register Form With MySQL DataBase In Java Netbeans



Java Make SignIn And SignUp Form With MySQL DataBase

The Design Part –

source code:

—————— Check out my Java Projects! ——————–

▶ Inventory Management System –

▶ Students Information System –

▶ Contacts Management System –

▶ All My Programming Projects Here –

▶ My Source Code Store Here –

————————– JAVA COURSE —————————–

▶ master Java core development step-by-step –

▶ TRY PLURALSIGHT FREE FOR 10 DAYS ( affiliate link ):

——————————————————————–

visit our blog

facebook:

twitter:

subscribe:

programming projects with source code:

C# And Java Programming Books

********************************************************************

in a previous java tutorial we did a login and register form design ( video link: ),
and in this one will see how to connect the login and signup form with a mysql database

to do that you need to download mysql connector, watch tutorial from here:
and add it to your project

we will ceate a class (MyConnection) to connect our login and register forms with mysql database

in the register form wi will create a function (checkUsername) to check if the username you want to register is already exists in the database table

what we will check when the user click on the register button:
– if the username jtextfield is empty
– if the password jtextfield is empty
– if the retype_password text is equal to the password text
– if the username already exists in the database using the “checkUsername” function
– if the jdatechooser is empty

in the login fom it’s simple;
the user enter his login and password and click on the login button,
and all we have to do is to check if a user with this username and password already exists on the database

other videos:

Create Login Form In Java With MySQL Database Part 1

Java And MySQL – Populate JTable Depending On a JCombobox Value In Java

Connect Java To MySQL Database

Bind a JCombobox With Mysql Database Values

Search Values From MySQL Database And Set It Into JTextfield

bind jtable from mysql database in netbeans

Bind JTable From MySQL DataBase Using ArrayList

Populate JCombobox Depending On Another JCombobox

Populate JCombobox From MySQL With Key And Value

How To Use Stored Procedure In Java And MySQL

Insert Update Delete Data In Database

How To Bind a HashMap From DataBase In Java

display Image From database To jtable

share this video:

source

User Registration System Using PHP And MySQL Database | PHP MySQL Tutorial | Edureka

User Registration System Using PHP And MySQL Database | PHP MySQL Tutorial | Edureka



(** PHP & MySQL Certification Training: **)
This Edureka video on “PHP MySQL Tutorial” will teach you how to create a user registration and login system using PHP and a MySQL database. This video covers the following topics:

3:40 Creating the database
5:30 Creating the registration page
11:23 Creating the login page
13:50 Creating backend logic for registration
28:05 Creating the home page
33:10 Creating the error page
36:30 Creating server logic for login

Check out our complete Youtube playlist here:

Do subscribe to our channel and hit the bell icon to never miss an update from us in the future:

Instagram:
Facebook:
Twitter:
LinkedIn:

#php #phptutorial #phpmysql #LearnPHP #phponlinetraining

————————————-

How it Works?

1. This is a 7 Week Instructor-led Online Course, 45 hours of assignment and 20 hours of project work

2. We have a 24×7 One-on-One LIVE Technical Support to help you with any problems you might face or any clarifications you may require during the course.

3. At the end of the training, you will be working on a real-time project for which we will provide you a Grade and a Verifiable Certificate!

————————————-

About the Course

Edureka’s PHP & MySQL with MVC framework will introduce attendees to PHP, MySQL, and CakePHP MVC framework. The course will cover aspects of how to use PHP, MySQL along with CakePHP MVC framework to create powerful and easy to maintain database driven websites. The course will also cover Installation & Configuration of PHP, MySQL, and CakePHP. Attendees will also get to implement one project towards the end of the course.

Why learn PHP & MySQL with MVC Frameworks?

PHP scripting and MySQL database are one of the worlds most popular open source techniques used to develop websites. Add an advantage of an MVC framework to it and you can develop powerful, dynamic and easy to maintain database driven websites. PHP, MySQL, and CakePHP are also platform independent i.e. You can easily port a website developed on a windows machine to a Linux based Apache web server with minimal to no changes. The CakePHP MVC architect also adds some additional security against threats like SQL injections, hacking etc.

————————————-

Got a question on the topic? Please share it in the comment section below and our experts will answer it for you.
For more information, please write back to us at [email protected] or call us at IND: 9606058406 / US: 18338555775 (toll free).

source