CRUD in Android Studio Java with SQL Stored Procedure Step By Step

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello viewers welcome to programming gig i'm here with a new tutorial that is complete crude operation in android studio using sql stud procedure with java [Music] okay first of all i'm gonna create a folder to create android application in the djv android tutorial folder with the name include android sql underscore sv yes the folder is created now the folder is empty now start android studio yes android studio is started now go to file menu and click on new project select empty activity click on next yes now name the android application android application name will be crude android underscore sql underscore sp and save the location select location location easy d drive android tutorial folder expand the android tutorial folder and select crude android sql underscore sv and click on ok yes now click on finish say that the android application is created in the directory selector directory remove this default text view and now i'm gonna design this uh page android face to far from crude operation so this is text view now change the text of this text view text is id and then select text in the pellet and drag the number edit text number and drop it in android page concentrate top right left and bottom and place it below the id okay it's done now i'm gonna add one more text view yes okay this text view text is name and then add a plain text edit text text person name okay now copy select this second text view and edit text person name and copy and then faced for address for address okay now add button this button is uh i'll use this button to insert records in the sql server database using android studio uh using stored procedure okay i just take three button for in insert update and delete to perform insert update and delete operation okay now this textview i will use to show message i mean after performing crude operation it will display the result okay now start sql server management studio and select your server name login essay password sql server password expanded database database name is crude android db i already created and the table name also now let's check the records in the database table so select star from user info underscore type the table name execute yes these are the records in the database table you can see id name address now i'm gonna create a stored procedure there is no stored procedure yet to create a stored procedure and sql to far from crude operation i'm going to create a stored procedure and ask you to file from crude operation okay create process insert user underscore sp integer id name and backer address at that address address also inverter then as begin end now mysql command sql command is insert into user info underscore tab values values will be id name address id command name comma add that address yes now select this procedure and execute yes commands completed successfully let's check the stored procedure exact dvd schema name dot insert under user sp this is the stored procedure name and there are three parameter id name and address id under five name jerry and address usa select and execute yes it's successfully executed let's check the records natively stable yes you can see one zero five jda usa is inserted successfully in this consolidation stability in front of tab okay now i'm gonna create one more stored procedure for updatable from update operation just copy and paste first of all change the store procedure name update insert user under scratch fee update user info tab set adequate id name this is the database table column name and that data name is parameter add that address equal to uh address equal to other address it will update based on id so higher at that of id equal to uh id equal to and that of id now select and execute yes it's a command completed successfully my a has to produce gears successfully now let's check the uh astropositive whether it's working or not change just to procedure name update user underscore sp usa to canada and jd to sandy peterson okay select and execute yes now let's check the records in the database table whether it's update or not yeah yeah let's check yes it's a successfully updated sandy canada 105 records now copy the update procedure and paste this procedure i will use to perform delete operation so delete user underscore asp and since the command command is delete user info underscore tab higher id equal to a third of id it's a need only one parameter to perform delete operation uh based on id it will delete the record based on id so that's to procedure is created successfully now let's check the uh store processing whether it's working or not so it's a one parameter so remove the rest parameter and the store procedure name delete user underscore sp execute yes let's check the records yes 105 records is deleted successfully okay now i'll use this to procedure in android studio okay now i'm gonna creating a class to connect with the sql server and android studio so surprisingly new fea public connection my class name is connection class now string ip [Music] fee of the server higher sql server is installed ford is default forty is one four double three if you change your sql server port you should put your port number of sql server database name db name database name database name is crude android db so database name equal to double quotation then crude android db okay now db user i mean database user database username is essay and database password is your sql server database password now stick mode stick mode dot thread policy policy equal to new stick mode dot third policy dot builder dot for metal dot build okay now stick mode dot set that policy just call this policy okay now connection connection connection equal to default connection is null then string click on your connect url url is also null now edit trikets try catch exception ex now message error message log dot e set error x dot twisting getting some get messes okay now class dot for name net dot george force i just uh coffee faced [Music] so that you also coffee face this connection is sting because if you want to write you can maybe you will get a miss a mistake of the syntax so just copy face from the description box below now change the variable db name db user and password db pass ok now connection connection equal to driver manager dot get connection connection url okay it's done finally return connection yes so it's done now go to the activity main now declare the value and declare the text view and button so text be id equal to text view find viva idr dot id dot edit text number id first text number id is edit text number so r dot id dot edit text number yes now copy it and face for the rest of edit text this is edit text person name and address addresses edit text person text version name two now button button btn add equal to button find b by id r dot id dot button yes this is button two and this one is button three so copy it and faced this one for btn update and between update is button2 and btn delete we can delete this button three okay now we can add dot set on click listener new view dot on click listener yes on click event is created automatically now connection con equal to connection class connection classes the connection class what i created okay now cats i just coffee face the catch option try catch okay exception ex okay now in this dry portion i will far from insert operation so if con not equal to null i mean if connection is okay then string q is query my query is exact execute dbu dot my store procedure name as well in certain id description id text view edit text number id dot get text dot twisting parameter uh first parameter is id and second parameter is name so name name is edit text text person name address address is yes address dot get text dot twisting okay it's done three parameters i have set three parameters now statement statement statement equal to con con statement now resulted result set result equal to statement dot execute query queue okay now it's done the text view 5 result id is text view 5 so declare the text b5 yes textbook id in msg okay now r dot id dot text b5 okay msg dot set text successfully edit okay expand the manifest folder under the f open the android manifest.xml file now i'm gonna add formation in android manifest user formation.name equal to androidformation.internet close the user permission and then user permission android name equal to android permission dot access network state okay it's done now go to the sql server configuration manager yes this is sql server configuration manager now check the tcp ip the tcp if is enabled if it's disabled you must enable the tcp ip and then restart the sql server now protocols for sql express here is tcp ip i'm gonna check the port now right click and go to the property in the tcp ip and go to the if you address yes now scroll down see that tcp dynamic port is three zero double six one higher is the default tcp port is one four double three so z three zero double six one now put uh four three zero double six one yes it's done now just debug yes it's debugging now let's check the records in the database table there are four records and i'm gonna insert one more record ide one zero four and the name name is trump address address is usa click on it okay now let's check the records in the database oh it's not added here's problem uh add the ills uh to check the sql server connection if con not equal to null then if connection is problem then it will display the message error in connection so run again yes it's running okay now 104 name trump address addresses usa click on its add error in connection i mean sql server connection is not working perfectly i mean sql server connections problems so uh now i have to do something more i have to add dependency in that case uh go to the f4 app folder open the app folder under the project your project open the library folder and in this library folder just put the jds 1.3.1.jar file yes the file you can download this file from the description box below or in the internet okay now go to the file menu click on project structure click on dependency click on f and under the declare dependency just click on plus sign and select the jar dependency go to the application again and just copy this directory of the jar file paste yes now for backslash and then the jar file name just copy the jds.jar file name select and copy paste it in the first click on ok yes yes my jar dependency is edit now run this f yes it's uh done now i'm gonna insert record there is only four records one two three now i'm gonna insert a record on the four name trump and address is usa click on it and let's uh check the records in the database execute yes one zero four trump usa is inserted successful in the sql servicing android studio with java code one more record id 105 name jenny address usa it and check again yes the records is inserted successfully i mean the code is working fine now get the code and change the font size of the button this is button add text size is 20 sp and copy this one for button update and delete and the text view also text by id name and address all the font size is 20 sp and text view result text b5 is color is powerful okay yes you can see the buttons font size and the textview color also changed now place it yes it's done now now i'm gonna perform update operation between update so would be an update dot set on click listener new view dot on click listen okay on click event is created now just copy this uh button add click event and paste it in there with an update click ok now just change the stored procedure store procedure is update user underscore sp so just change the stored procedure and the parameters are also same uh that for three parameters in insert and three parameters in update so all are same just in the message successfully updated and the rest of the things are same now delete between delete dot setup listener new view dot on click listener okay now just copy the update code uh from on click and paste here oh con error or coffee disconnection also yes okay now it's done things that uh the there are one parameter in delete stored procedure so i will put only one parameters in delete stored in delete button so delete is under is velocity and there's only one parameter rest of the parameter then two more parameters just delete the two more parameters yes successfully delete it now apply change and restart the activity okay go to the sql server yes now 105 records delete the 135 records let's execute yes the 105 id records is deleted successfully okay now 104 usa to canada update uh yes yes it's updated successfully id 104 and i'm gonna insert uh one more record id105 name trump canada add yes the trump canada is inserted successfully now create one more store procedure to get data from sql server database to android studio using stored procedure so create ports uh select user get yes get under squeeze under scratch fee and parameter one and since the sql command sql command is select star from user info underscore tab higher id equal to that of id okay it's successfully created the stored procedure let's check the stored procedure get use underscore exact get user underscore sp parameters on there too parameter is one parameter id so id yes now one zero three yes it's displaying records only one zero dollar id is one two three okay now resize this text edit text number to place a button beside of edit text number okay now copy this button and first place this button beside of edit text number id okay text is get yes and the id of this button is button for you can see in now first of all declare the button button four so this button is forget so we can get and ids button for okay now create a click event of button four so btn get dot set on click listener neo view dot on click listener now on click event is created now copy the on click code from the btn delete and paste it in median get okay parameter is more single file one parameter and that's the positive name is get user underscore sp so just change the store procedure name get user underscore sv okay query okay id now remove this msg and here add a while loop while result.next then name name tagbox name dot set text result.getsting index index start from 1 so name is in the second index 2 and address is in the third index so address three index address columns index is three okay now android is starting yes started successfully now foot id one zero three get yes redoi address five bit five yes you can see now select start from user input obviously these are the records now i will check based on this records one zero zero john usa it's working fine if one zero one then christian uk yes if it's 104 then jenny canada thanks for watching this tutorial [Music] you
Info
Channel: ProgrammingGeek
Views: 183
Rating: 5 out of 5
Keywords: programminggeek, crud in android studio with sql stored procedure, crud in android studio with sql server, insert update delete in android studio with sql server, crud in android studio with java, insert update delete and search in sql server using java, insert in sql using android studio, update in sql using android studio, visual studio code, crud in java, virul
Id: hi7rg9rzsmk
Channel Id: undefined
Length: 25min 41sec (1541 seconds)
Published: Mon Sep 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.