NEED TO LEARN JAVA – 5 FREE JAVA VIDEO COURSES – CLICK HERE – https://goo.gl/7i95F8
View more videos on my “Java JDBC Tutorial” Playlist: http://goo.gl/crT4nS
Closed-Captioning and English subtitles available.
In this tutorial, you will learn how to update data in a MySQL database using Java JDBC.
Download Source Code: http://www.luv2code.com/?p=746
Please subscribe to my channel. http://goo.gl/EV6Kwv
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.
Time – 00:00
Hello. In this video, you will learn how to use Java JDBC to update data in a database. In regards to prep work, you must have a database installed. This demo will use MYSQL. You also need to have the database driver configured. Again, we’ll use MYSQL. If you need help on how to do this, please look at my other video, Connecting To MYSQL Databases with Java.
Time – 00:30
In this example, we will use the Employees table. This table has columns for employee ID, last name, first name and email address. Let’s switch over to the MYSQL tool, so we can take a look at some of the data.
Time – 00:50
Here’s our sample table that we have with sample data already in place. What I’d like for you to do is make note of David Brown’s email address. He is currently listed as [email protected] We’re going to change this email address to make use of luv2code.com.
Time – 01:13
His new email address is [email protected] The following sql can perform this update. We will use this sql update statement in a Java application.
Time – 01:26
This slide outlines our Java development process. First, we will get a connection to the database. Then we will create a statement. Finally, we will execute the sql update statement. Let’s move onto our development environment and get started.
Time – 01:46
We’re going to start with a simple Java program. The program is going to start out with the url, the connection to the database, the user ID and password.
Time – 01:56
The first thing that we’ll do is we will get a connection to the database. Then we will create a statement. Then we’ll actually execute the sql query. This is the same query that we had from the previous slide.
Time – 02:12
Then we’ll actually do an execute update. This will actually send the query to the database and perform the update. Finally, just to give us some debugging information, we’ll have a print-line statement to say update complete.
Time – 02:27
Let’s go ahead and run this application. Run as Java application. It says update complete. Great. Let’s go to our SQL tool to verify the results.
Time – 02:42
In the SQL tool, I just simply do a refresh and note the new email address for David Brown. It’s now [email protected] That works out, and we’re actually successful with updating data using Java JDBC.
Time – 03:00
This wraps up the presentation. If you’d like to download the source code, please visit the website luv2code.com.