RUVIDEO
Поделитесь видео 🙏

Java JDBC Tutorial - Part 2: Insert Data into a MySQL Database

📁 Лайфхаки 👁️ 16 📅 05.12.2023

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 use Java JDBC to insert data into a MySQL database.

Download source code from
- http://www.luv2code.com/2014/03/21/java-jdbc-insert-data-into-a-database/

Please subscribe to my channel. http://goo.gl/EV6Kwv

----

Follow luv2code:

Website: http://www.luv2code.com
YouTube: http://goo.gl/EV6Kwv
Twitter: http://goo.gl/ALMzLG
Facebook: http://goo.gl/8pDRdA

---

Join my mailing list: Get advance notice on new tutorials. Emails about 1 per week.
- http://www.luv2code.com/joinlist

---

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 video, we’re going to learn how to use Java JDBC to insert data into a database.

Time - 00:10
As for as the prep work that you need to have taken care of, you need to make sure that you have a database already installed. In this example, we’re going to use MySQL. Also, you need to make sure you have the JDBC driver installed for your database. In this example, we’re going to make use of a very simple table called employees. This table is going to have four columns. It’s going to have the ID, the last name, the first name and the email address.

Time - 00:44
Now, let’s take a look at this table in our SQL query tool. In this example, I have the employees table. I run and select star against that table, and I have my output. We have three employees in the database right now: John Doe, Mary Public and Susan Queue. Now, if we wanted to actually insert data into the database, we could use the query tool and we could use the statement here. “insert into employees”, specify the columns, last name, first name, email, and then the actual values.

Time - 01:26
What we’re going to do is take this information and actually use it in a Java program. Our basic development process is, first, getting a connection to a database. Second, creating a statement, and third, executing the SQL insert. Let’s move over to our Java development tool.

Time - 01:51
In this application, it’s a very simple project. What we need to do first is get a connection to a database. We’ll have Driver Manager get connection. We give the URL, the user ID and the password. Once we have a connection to the database, then we can create a statement.

Time - 02:16
I’ll say, “myConn.createStatement” and it gives me a blank statement object. Now that I have a statement, I can setup my SQL. The SQL, I will assign it to a string variable. It’s the same SQL we saw in the previous slide. “Insert into employees”, I give the last name, first name, email, and then I’ll also provide the values: Brown for last name, David, and then that person’s email address. Now that I have the SQL, I make use of the statement here, “mystmt.executeupdate” and I pass in the SQL. This will actually execute a SQL code against the database.

Time - 03:03
Then when I’m finished, I’ll just do a system out print line, “Insert Complete”, and then I have my normal exception handler for the code. Let’s go ahead and save this and let’s run it as a Java application.

Time - 03:18
I’ll say execute. Note at the bottom it says, “Insert complete.” Now we can go through and actually check this against our database. If I run the query one more time, and now I can see the statement or the new entry here for our new employee, [email protected]. We were successful.

Time - 03:48
Let’s go ahead and wrap up. We were able to insert data into a database using Java JDBC. If you’d like the code examples or more video tutorials, then visit luv2code.com.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java JDBC Tutorial - Part 2: Insert Data into a MySQL Database», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.