JDBC (Java Database Connectivity) in Java in 6 mins [ JDBC in Java ]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my Channel today in this video we will learn how to connect to myscale database and visual studio code using Java so let's start so first we have to create a javaman project for that so for that I will come to this settings and command plate leads and here I have searched the create Java project which is this one and now I will select this Marvin and here we have to select the archetype quick start and I'll select this version and now here I will provide the group ID Kiam and for artifact ID demo is uh perfect you can change it or I will change it to test and hit enter and now here we have to create or select folder so first I will create a new folder I'll select this new folder and I'll use give it a name connect MySQL and now I'll select this and select destination folder and it will start creating the product now when this snapshot appears so press enter and now here we have to provide the y for yes and hit enter our project is created now we will open this so I'll click on this open so now the project is opened so this is the source and if I go to this man and app.java this is our main class and this is our form dot XML where we will add our drivers so to download the driver we have I will go to this browser and I'll create a new tab and I'll use a Marvin Central repository and I will select this first one and now here I will search for my schedule J connect.net enter so now it will load so we will select this latest one now I'll come down and I will copy this dependency and copy this and now I'll go to this Visual Studio code and form.xml and now I'll go down to this dependencies section and now outside this dependency tag I'll paste this now remove the space and now all control is now is Select yes and now we will go to our app.java now let me show you the database so I have started same control panel so you can see it here and my schedule is dotted as well so if I come to this browser I have opened the localhost here so this uh my DB I have this table is TD and we have this one record in this and we will retrieve This Record connect to this database my ADB and retrieve this record so now I'll go again to this uh and I'll remove this slide and now here we will write our code so first we will create the URL of the DB so string URL equals to use here jdbc and MySQL full column then forward slash forward slash and then localhost then the port number as you can see here in same control n and that my cable is used 3306 so we will use three three zero six so three three zero six and then forward slash n then the data is named my DB and now I'll put semicolon here now we will create the DB user and the password so string DB user equal and we are using the root user semicolon and strength password equals uh empty and now I'll put semicolon now we will create the connection so connection con equals driver manager dot git connection and now the first is URL then the user and then the password is taken automatically and now I'll put semicolon at the end Ctrl Z this and semicolon at the end now this is showing error because we have to enclose it in try cage or add surround it with try cage or it throws a declaration so I'll add those declaration now we have made our connection so now we will create the statement row statement SD Mt equals con dot create statement and all put semicolon and now this statement is showing error so if I click on this and quick fix is so we will import java.s cable statement and now we will create our query so try and query equals select state it from STD which is or tablet semicolon now we will use result set RS equals uh stmt dot execute query and now we will put semicolon at the end now this is done so we will use while loop while RS dot next then get the values so um the string or end ID equal to RS dot uh get end and here we will pass in the column Name ID and now I'll put semicolon here at the end where are these column names coming from if I go here to database so you can see this is ID name father underscore name and address these names we are using there so I'll copy this Ctrl C this and now all Ctrl V it here and now I I'll use the string and use your name and rs dot get string and here we will use name and now I'll copy this Ctrl C this and now I'll Ctrl V down here and one time again and now I'll name this string F name and here I'll use a father underscore name and this will be address and here I'll use address and now we will show this and terminal so system dot out dot print Ln and here we will use double quotes ID plus ID plus double quotes space space and then name uh colon space and here we will use plus name and then plus double quotes and space space and then if name I have to create a space here plus F name and then plus double quotes space space and address and space full column space and plus address and now here I will create a space as well display now so our code is complete so let's run it and check this so I'll click on this run button so now the code is running and you can see id1 name tanveer if name uh Han and address uh and your terminal I think that's all for today I hope you like the video if you like the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 3,519
Rating: undefined out of 5
Keywords: jdbc, jdbc in java, jdbc connection in java, java database connectivity in java, what is jdbc, java data base connectivity, jdbc connection, jdbc drivers, jdbc tutorial, java database, java jdbc example, java jdbc tutorial, java jdbc connection example, introduction to java database connectivity, java database programming, java database connectivity jdbc, jdbc example programs, what is jdbc in java, jdbc in java tutorial for beginners, java database connectivity
Id: RQY97aTjGyU
Channel Id: undefined
Length: 6min 26sec (386 seconds)
Published: Sun Apr 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.