PreparedStatement: Need of PreparedStatement

DURGASOFT DURGA
A free video tutorial from DURGASOFT DURGA
Trainer at DURGASOFT
4.7 instructor rating • 8 courses • 113,501 students

Learn more from the full course

Complete JDBC Programming Part-2

Direct Class Room Videos To give Left and Right Anywhere about Java Advanced Database Programming

31:19:29 of on-demand video • Updated August 2019

  • Students can get complete in-depth knowledge on advanced concepts of JDBC. After completing this course students in a position to write code confidently for database programming.
English [Auto] So now I will explain what he does. Prepare the statement said our lady will use that a simple statement not my statement SD equal conduct creates statement but no more. A drawn to the statement. I want to yours. What did that statement is. Prepare this statement. Are you getting that. What did the what of the statement mechanical to spell out. Prepare to prepare the statement said the name itself indicates this statement is already prepared a holiday prepared that you require to use it. That's how they're getting into this estate mentality prepared it. You're required to use prepared a statement which is already prepared. What is the meaning of that. That part I will discuss said no. A D will you will set a one to one one statement like what did that statement stop. Not a moral statement correct Lieutenant what is only one statement we use are not among the statement said no hold. You got normal statement object you can get normal statement object calm not panic and explode gone down again. Statement are getting such a statement SD a code of conduct could be a statement like this we could get that statement object but no the point p s take very very very special. Get your board. They said that not it. What did that important point is sir. I'll tell me which statement. What did the need are going for a prepared statement such as just a simple you may get performance improvement. You may get performance improvement you make it more convenient to use that simple said Southern India. Elliot mantle mantle carries the headset. One day with one leg. You will get caught in a.. Got it. We'll leave you to one like you. You can able to get the out. Sadly no. Strictly speaking it is a court that's a namesake God. But backside said if you are going to stay here just like it is. I don't to get that. OK. Next to for long goodness I want to travel thousand km. Can I use an a.. No. It is a problem solved. So then automatically yes we will go far. OK. Next the level. OK next to level maybe eight twenty eight twenty at something like eight one days hand. Right. And like I'm going to use is you assume that when compared with the nano said I 20 are otherwise 8 and not otherwise. Like is that like a d up above. Gaza will provide more convenient more convenient good seating arrangement and extend the same time long the journey speed. Pick up a thing is available like some known so I want to travel almost double the frequent parallel resume that I travel long distances more comfort nice by default I won't. Then immediately next level we will go far that Audie are regretting it that Audi are BMW something like capital you can go for that sum you d your car. He doesn't see a car. He did not say you got. Why did the difference between the man or just the one layer three member seating capacity issue. Sadly if you can go for it one day maybe five member seating capacity they have equal fun next to level fortunate that something like you may get some eight members at nine member seating capacity. More spirit more. Be like that things have gone to be there sir. How many level of course out there. Basic model. And once the model next on top of that you know more more facilities. Some super laxity more like you make out several like why don't you call Sam number of statements you know about GBC also how to getting something like a nano ICL statement object something like that or a statement object. Saturday night lover twenty five one day six programs whatever we use at the Nano car to send over the school body from Java application to database mix the level is at nothing but prepare the statement as you on that desk so that you will get some some basic idea OK prepare the statement Oh next level. Gotta start OK prepared state ban is going to provide more facilities for us then with the statements on the facility that we will take it don't worry next time. So when compared with type one day. Audi BMW more security by default more will be the next US please pick up an extra look very happy but you will be there. Such a type of car these are not the my car La Bella statement. What did that's not going to get explored. Carla Butler statement. Remember that Carla but this statement so don't fear you get ABC. We have only one statement sir. There are three types of statements are available in Jeddah. Very important question for them right on set in Jeddah is how many statements are there. Three. Why did that pass one simple statement. Not most statement. Second one son prepared this statement. Todd one some colorful statement. Keep these points in your mind. Next to two topics what we are going to discuss prepared statement on the caliber of statement of only but you should be aware what did one day just by default we are going to get with that. This event compared with the statement object of getting basic idea right. So now what topic we are discussing preparing the statement. Remember prepared at a state when Sara when compared with an animal statement there are some benefits out there like him Jedi B.C. how many statement objects are available. Statement prepared statement Karla bold statement. Keep these pointed out of mind. No. What did the next. I've got some. Just keep these things in your mind so that we will discuss light in detail. Don't worry about that. So what is the problem with the statement object. Why we should go far. Prepare the statement already statements there. What did the what did the problem with this statement object. What did the mean. Off prepared statement that parties of other concept lay sub known. I want to send one school committee said yes to Don execution. Sadly the execute periodic secret update not any matter. No problem at all sir. Now I have to pass my credit. I assumed that such few policy rescue equity if you possess equal equity started by using simple statement object you think what will happen is yet that I may say it too yet but this will be fed formative. What did the past activity. Just not like about in the last video. What did the perspective a compilation second activities to execution out of getting you feel send this girl pretty by using statement object you put it pain you retain it everytime. Some of the query will be compiled you've retained that but it will be executed. Then I will get the result liked. Remember that even you are passing simply the same query podium time also are getting even. You are passing seem pretty cogent times also sorry I'm passing Sam pretty Sam Selectric. Wait a second I thought I thought that I told you I'm lying to you every time every time. Can you please compile everytime compile under execute combined under execute. Area. Gary's already seeing already back. No. Every Vic sets up company executive comp. execute like this right. Getting. So in that case are simple state men sorry if you are sending gas reliquary yet the database hide it for a time that body will be compiled under executed. Remember that. So what is the problem with this approach. Abdullah Abdullah a bit carefully said in this. What is the problem with the statistics I will. I will explain so that you people can evade son such as you have done. This is my Java application set up very carefully. It is Java application which is internally using Jedi basic concept. So no I'm sending my yes girl but a total database as you meet may be what I call database out of my ESL database. Anyway to some database I gotta this my pretty sad now. I'm sending guys good luck with it. Just observe that. So you did. It was that time to send this girl pretty sad sometimes when I can use the word request to send that request out. Once the query reached the database to activities are going to be performed. Sir can you spell out what the past activities are. Okay. What are the past activity compilation of compilation. What did the second activity will be felt for himself. Execution are getting compilation next to execution. Once the execution complete dead center that result the door job application form that sometimes is required. Let me consider that by whom. Yes. Response. I'm getting so consider that I met my sponsor. Okay. So this is the case in the case of simple statement. If you send Eskil a petty complaint execution provide that response send compile execution provide the respond whether you are sending same query are different very processes always the same. If he does simple statement legally now observed that some time time bottom bottom one he said if I want to. Good time for one party suddenly secret one party. How much time he's going to be taken up. Just done. We have to consider a request that time like start paying. Plus we we're required to consider compile time collect that. We have to consider compile time. Plus we have to consider execution time execution time. Plus we require a considered response time also is used. That's a start. All these are timings compulsorily required to consider so request are buying 1 milliseconds compiled thing 1 milliseconds sad execution thing 1 milliseconds response something 1 milliseconds is your resume set some time of 1 3 1 query how much time is required for milliseconds time is quite good. Sara analyze a mathematical point of view I want to explain with that I put the performance light side I want to pay him Potter told gender his maybe critics see him quitting at the front. He said in the case of simple statement whether you are sending same query are different getting more different set out compulsory everytime that query will be compiled and executed. That's why I am bottom cogent queries so that very maybe some maybe somewhat different. You are sending you lot a credit Argentines man. What will happen. That almost I that a quite please that one small part of one query execution for millisecond. For Jennifer this execution set our agenda in store for millisecond what your body values are for all gender. Leszek ends clear how much how much time he's going to take some 4000 milliseconds it's going to take said DC at that time required in the case of simple statement object everyone can able to understand something. This one this simple statement this approach not suitable in some cases like sort of weird weird stuff where this type of requirement to ease it is not gonna be fulfilled. But keep this diagram in your mind because that is on air. If I if I'm using of prepared statement then you're never gonna get 4000 milliseconds right sort of mantra just 3000 milliseconds and maybe maybe same requirement if I do prepare. There've been 3000 military and is gonna be opened up but I will discuss if I use bad templates concept bad template concept 2000 milliseconds only. That's why it's that big a bit very very special. Get this that. GRAHAM This approach is that very important. Remember that said no. In that case of simple statement if you send that skill put it to the database you retain that query will be compiled and execute there. Even same whether you are passing intelligent things the you on things will become pilot podium time will be executed at least for a lot of it. I adopted this sudden No you know what programming requirement. It's a very common to execute same query multiple times so it's very common in other applications like the exact same coding multiple times. Best example for you is that I have CTC application a data as your major. I say this application I did. I wanted to check up what are the various airplanes from Hyderabad to Mumbai. I want to check to internally we just feel what he's going to be executed. Can I can I spell out to select huh. Can I can I spell out select a start from select start from insert sir resume is that are planes at table set of where their source is equal to hide that are but their sources equal to high drama and the destination is equal to Mumbai like girl like this. So this nation is equal don't Mumbai it's resources equal to that bottom. This nation is go to Mumbai like I'm taking some goodies now my questioning is this equity even I got CTC application how many times are it is required to execute yes lacks uptime so maybe maybe saw some destination places maybe different to some parts on message for Billy animal by some bothersome message for them OK. Hyderabad in Bangalore. Some maybe some of it who towards some other destination some maybe different. But to see him pretty see select equity how many times it has to execute in the yard say this application like Sir lacks ofttimes Pirate Bay Pirate Day legs up times it has to execute. I hope everyone can nail down a Sunday. At ease it does seem curious different query. Same query but maybe with a different input values but queries always came up not a guess second answer. Let me consider said I hope you people make your rare book my show application. Yes ma'am. You never use it in movies or movie tickets if you want to. If you want to book a book movie ticket then what. We should go to book my show. I want to know I want to know something which in the theater. OK so this a particular movie's playing is used to select to select the star select a star from from the year. That's from how I select a star from theaters that get us there. Their movie name their movie name. Can I can I spell out any any movie names. Yes. Any any movie. Okay. Yes. Okay. So where movie name right. Yes. Next enough then. Okay. So city city is equal to Mumbai. City is equal don't Mumbai. Like this I'm asking some. This equity in my show. How many times he's gonna be executive legs sometimes maybe movie name different city name different. But the query SELECT equity how many entity has state secrets that like something you've said to him for the ball well you do I don't know but then we did the believe too playing I will set see him Select Equity maybe movie name on the city name maybe different set of Bangla the person he wanted chica. We're not done loop volume is available like he's going to search it then automatically something like the D equity in the city's application has to execute on dominate time saying still lacks up things a legs up things but today in a young city application look my show application like everyone can able to understand so in our programming required Min OK seem ready required to executor multiple times a day with the same input values are different input value same query required to execute multiple time follow such a type of what is if you are using simple statement object follow such a type of grid is if you are using simple statement object for performances quanta we don't like anything remember the it does seem query required to execute multiple times and never never never come on then to go from simple statement what did the problem solve the problem here. How did queries are facing queries on with him if I send the one that one one lacked things. If I send the one lag time so same query same query you put it that simple step in what will happen is that I database say you've written will be compile you've written will be executed remember it everything will be complete with them will be executor that equities are waiting for this advise him already compile let it compile what is position second and third time for today months on that it's got a problem with the simple statement object everyone can able to understand it in that case are simple statement object simple statement object sorry retain that but it will be compiled under executed even talked with ease I seem ready to write. That's why for repeatedly if you want to execute the same query multiple times multiple times same very never never never recommended to go for one statement object Beka if I want to execute one query one that things one thing then for you use if a using it statement one let time sir the query will become blunder execute then are you able to on a Sunday. So you are seeing some performance at the grid with the statement object to role will come this a problem we should go far prepare this statement getting that we should go forward with these statements I'll prepare a statement remember that then immediately mask. So what they had wanted a prepared statement what they need or prepared what they had once they got prepared statement when compared with the simple statement so like come on queries data as you might assume very very carefully set up iPhone one query is there one queries Datsun this activity I want to execute one lac. Things are getting how many times I wanted to go out one one times I want to execute if I use the simple statement if you want so simple statement how many times that he will become pi how many times that but he will be executed in one lat good times 1 lac times compilation one lac times compilation under one lac times one lac thanks completion one lack good time sir. Execution is going to happen remember that. Sorry for your simple statement bad but you for yours prepare the state man observe observe very carefully sir you fight yours prepare the state men how many times you want to execute this one let things like one let bank how many thanks to that but he will become by one bam warned Lee one time compiles and yet they're never going to compile one let things how many times it is gonna be compile what only ones only one time compiling QA plus blah how many times it will be executed to one lack things it will be executed that one leg pain sir execution OK that's not so or if any person is asking what is the important difference between simple statement and a prepared statement what answer do you condemn such a prepared statement for performance wise. Good good because in the case of simple statement if you send the same query one lacked themes one lack basic will be compiled and executed then subtle like one like thanks will be compiled but in the case a prepared statement how many times query will be compiled only one so one thing competition is in r but for the time it will be executed no problem at all sort of one lac times we are not required to compile automatically how much for performance improvement body part will be that you can able to expect list for a lot of it and that's why I make sure sir. What did the main advantage of prepared statement why we should go for a prepared statement already statement object is a there just start to improve performance. Sorry to see a lot of you. We should go for a prepared statement. You seem ready at this point to execute multiple time then best suitable concept here. Prepared a statement. Sort of hold up performance improvements buddy Paul will be dead in the prepared statement. In the case of simple statement you think think they will be compiled and executed but in that case a prepared statement clearly will be compiled warmly leave once getting ready will be combined with only one sir. But the execution will be happen lacks uptime based on a robotic madman type. Okay. That's hard. So they haven't got a basic idea. Your bored. What did the need off prepared statement. Just to keep only one by deliveryman. If I go for a admin performance improvements out there. Look at that site because plenty will be compiled only once I get that point in you mind. Then automatically you people are unable to understand. Next Thursday mining things they suddenly see the basic introduction of prepared statement. That's I like. Didn't attack much so the statistics are clear. I will explain. Don't worry about that said think.