Java JDBC Tutorial – Part 6.4: Calling MySQL Stored Procedures with Java
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
Download Java Source Code: http://www.luv2code.com/?p=1026, Follow Me on Twitter: https://twitter.com/darbyluvs2code
Please SUBSCRIBE to this channel: https://www.youtube.com/user/luv2codetv?sub_confirmation=1
---
In this video tutorial we will learn how to call MySQL Stored Procedures with Java. This video covers stored procedures that return result sets.
---
Transcript
Time - 00:00
Hi, this is Chad (Shod), with luv2code.com. Welcome back to another tutorial on Java JDBC. In this video, we will learn how to use stored procedures.
Time - 00:11
In this video, we're going to focus on stored procedures that return result sets. Check out my other videos that covered different types of parameters, such as IN, and INOUT.
Time - 00:22
For this tutorial we will use the following table, employees. The table has a sample data for testing. I havea a SQL zip file that you can download, it'll create the table, add sample data and also set up the stored procedures. You can download it from the link below.
Time - 00:39
We'll call a stored procedure that returns a result set for us to process. Our DBA created a stored procedure called "Get Employees for Department." The first parameters the department main, and the stored procedure will return the results as a result set.
Time - 00:55
To call the stored procedure, we prepared columns before. Using a question mark as a parameter place holder. We set the first input parameter as the name of the department. Then we execute the stored procedure. Once the execution is complete, then we can retrieve the result set by calling, get result set.
Time - 01:15
Okay, so let's switch Eclipse and see this in action. I have a sample Java program called, Get Employees for Department. Let's walk through the code. The first thing we'll do is get a connection to the database. We'll also set up our variables for the department name. Then I'll prepare a call to the stored procedure. I'll make use of the question mark as a parameter place holder. Then I'll set the parameter value. I will actually call the stored procedure. Then I will actually retrieve the result set from the stored procedure. Now, I'll call a helper method that will actually display the result set.
Time - 01:53
Now, let's go ahead and run the application. As we can see we make a call to the stored procedure, we pass in the department for engineering, we get the results, we call our helper method and it displays the results. Which looks pretty good. Let's go ahead and verify this in our SQL tool.
Time - 02:17
I'll move over to the tool, I have this query, select * from employees where department equals engineering. I will execute and I get four results. This matches with the information that we have from the Java program. This looks very good, so we're successful.
Time - 02:35
That wraps up our discussion on stored procedures using result sets. We were successful in calling a stored procedure and passing IN parameters. Please subscribe to our channel to view more videos on Java. Click the thumbs up to like our video. Also, visit our website http://luv2code.com to download the Java source code used in this video.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java JDBC Tutorial – Part 6.4: Calling MySQL Stored Procedures with Java», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.