Connect MySQL Database with Java (JDBC) in VS Code.

Ғылым және технология

This video explains about how to connect your Java Programs which are meant to connect MySQL Database using JDBC Driver, provided by MySQL Installation (or) through separate driver download, from official MySQL website. 💻🔌
📕 References:
📗 MySQL Community Server Installation:
1. dev.mysql.com/
2. dev.mysql.com/downloads/
3.1 dev.mysql.com/downloads/mysql/
3.1.1 dev.mysql.com/downloads/windo...
3.1.2 dev.mysql.com/downloads/insta...
3.2 dev.mysql.com/downloads/conne...
📙 Microsoft VS Code Installation
1. code.visualstudio.com/
2. code.visualstudio.com/Download
📘 Java SE JDK Installation:
1.1 www.oracle.com/java/technolog...
1.2 See my previous videos on the topic "JavaFX in VS Code", where I have shown you how to install Java JDK, in detailed.
⌚⏱ Timestamps:
00:00 Introduction
00:47 Installation
04:22 Creating New Project
06:30 Programming JDBC Code
07:25 Importing and Programming
08:08 MySQL Terminal
10:40 Testing
13:40 Conclusion

Пікірлер: 140

  • @harshith_takkala
    @harshith_takkala3 жыл бұрын

    As many of them are getting the issues regarding the ERROR: java.lang.ClassNotFoundException: I would like share few points. May be: 1. You haven't imported the correct jar file (jdbc driver from MySQL Installation) 2. Try to clear the workspace cache in VS Code. (don't know how but sometimes VS Code recommends me to do by a notification) 3. Restart the whole procedure... 4. Replace the statement "Class.forName("com.mysql.jdbc.Driver");" to "Class.forName("com.mysql.cj.jdbc.Driver");" (suggestion given by VS Code terminal) Hope it helps. 5. Or the main reason can be, you may not set the path for MySQL bin folder in either system variables or user variables.. The file hierarchy that must be running currently in VS code must be as follows: ProjectName { .vscode { settings.json } lib { } src { App.java } README.md "Debugger for java" must be installed, so that "Run Java" option will be visible to compile and run. Hope it works. ✨😀

  • @DAOXINNo15

    @DAOXINNo15

    2 ай бұрын

    what if we get this instead about PS C:\Users\user\Desktop\MySqlProject\FInalJBDC> PS C:\Users\user\Desktop\MySqlProject\FInalJBDC> ^C PS C:\Users\user\Desktop\MySqlProject\FInalJBDC> PS C:\Users\user\Desktop\MySqlProject\FInalJBDC> c:; cd I no longer got the error of this ava.lang.ClassNotFoundException: when I did the class change as you said and restart the project from scratch but I just get that with what I showed you above now instead of printing out the tables or anything

  • @janhavipimplikar6048
    @janhavipimplikar60482 жыл бұрын

    This explanation is a lifesaver! It was really difficult to find JDBC tutorials in VSCode but this one nailed it .Thanks a lot for uploading this video!

  • @arthurbttf
    @arthurbttf2 жыл бұрын

    You are the boss! No one else has explained where this goddamned classpath was, you're a literal life saver!

  • @tinayetsinakwadi8906
    @tinayetsinakwadi89063 жыл бұрын

    Thank you so much my man. You are a life saver. You deserve many views. Ill try and share with as many people as possible.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Thanks !! Check out my other videos too!!

  • @bagwanmohdhuzaif1263
    @bagwanmohdhuzaif12633 жыл бұрын

    Thanks I am trying to run the first jdbc program from last 5 to 6 and your vedio helped thanks so much it really helped

  • @ryansatriayudha
    @ryansatriayudha11 ай бұрын

    This video is very helpful. I have tried many times watching other videos but never work. This works well after many mistakes. Thank you very much! Best wishes from Thailand.

  • @wagnerdds
    @wagnerdds2 жыл бұрын

    Thanks for your tutorial. It saved my life!

  • @husnajaved7514
    @husnajaved75143 жыл бұрын

    I'm very grateful to you Sir!!You did it really well

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Thankyou ! Check out my other videos too !

  • @ZoomerApp
    @ZoomerAppАй бұрын

    Well, thanks so much man. It actually worked for me!

  • @LightWalk3r
    @LightWalk3r Жыл бұрын

    Thank you, this was super helpful

  • @yunusshaikh7478
    @yunusshaikh74783 жыл бұрын

    thank you so much . It really helped me

  • @akshattrivedi4164
    @akshattrivedi41642 ай бұрын

    Great tutorial man 👍 Still working after 2 years!!

  • @abstylegaming
    @abstylegaming2 жыл бұрын

    Thanks bro Awesome Tutorial!

  • @yugansh4356
    @yugansh43563 жыл бұрын

    Thank you so much you deserve much subscriber

  • @nisarg001
    @nisarg0013 жыл бұрын

    Thank you so much bro. I was going to switch to ecllipse but you saved me.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    😁😁 My job done, I was expecting a comment of one of this kind. Thanks!

  • @carladomingomiquel4744
    @carladomingomiquel47442 ай бұрын

    you are the best!!!! thank you so much!

  • @PrernaSharma-yl6ih
    @PrernaSharma-yl6ihАй бұрын

    Thanks a lot😭, I was struggling in running this program for 2-3 hours.... Finally I got the solution while scrolling through the comments...Thanks once again..

  • @OsomWay
    @OsomWay3 жыл бұрын

    You are a monster. Thank you bro!

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    😂

  • @ahmadshodikin262
    @ahmadshodikin2622 жыл бұрын

    thanks, it really help :)

  • @AmanKumar-wu3ej
    @AmanKumar-wu3ej10 ай бұрын

    Thnaku bro you are life saver

  • @kiaehe6292
    @kiaehe62923 жыл бұрын

    thanks innovator, fyi for some of you guys out there, here are a couple of errors i got and their solution 1)The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. the solution is to change line 7 to :-Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/invoicing","username","password"); and change the 0 to 1 on line 12 jic.

  • @hilmanaziz
    @hilmanaziz3 жыл бұрын

    another great video

  • @harshith_takkala
    @harshith_takkala3 жыл бұрын

    Like if you find it useful. Cheers !!

  • @tejasbele1456
    @tejasbele14563 жыл бұрын

    Thank you so much...

  • @raheenbagwan2240
    @raheenbagwan22402 жыл бұрын

    Thank you so much

  • @anmolverma2911
    @anmolverma29112 жыл бұрын

    Thanks 🔥🔥🔥🚀👍

  • @vidyatrimbake480
    @vidyatrimbake480 Жыл бұрын

    Great!!🌻

  • @t.a.f.6736
    @t.a.f.67363 жыл бұрын

    Thank you!

  • @toriljain2711
    @toriljain27118 ай бұрын

    thank you bhaiya

  • @nitigyajoshi4658
    @nitigyajoshi46582 жыл бұрын

    thanks a lot sir

  • @ommule4999
    @ommule49992 жыл бұрын

    Just a small doubt, when I run the code its displaying the output in the debug console. Can u suggest a fix ?

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    The "Debugger for Java" extension is responsible for running and debugging a java program. May be: 1. You are clicking on "Debug Java" or "Debug" instead of "Run Java" or "Run" 2. May be you are clicking "F5" (shortcut for debugging the program). If not working, then I dont know, If you got the solution, please share here. 🙂

  • @udaan878
    @udaan8782 жыл бұрын

    i am facing an error in class.forname(in this loction )it is saying com.mysql.jbdc.Driver() doesnot exist. What should i do now ?????????

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    I think you havent included the driver jar file into the project.

  • @crimson4706
    @crimson4706 Жыл бұрын

    may i ask you how to show all the columns? i have three columns and it only showed one column

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    The query has to be "SELECT * FROM and also in the println statement inside the while loop, it must have same number of functions as that of columns to be printed with indices starting from 1.

  • @shivamseth2851
    @shivamseth28513 жыл бұрын

    dhanyawad :-)

  • @parthjaiswal6151
    @parthjaiswal61513 жыл бұрын

    nice learning from a fellow vitian

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Hii🙂

  • @jurislaivins215
    @jurislaivins2153 жыл бұрын

    So strange. I have looked at 20+ Tutorials and I always have this issue: ERROR: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver I just can't make it work. I did step-by-step what you did here and still same issue.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    May be: 1. You haven't imported the correct jar file (jdbc driver from MySQL Installation) 2. Try to clear the workspace cache in VS Code. (don't know how but sometimes VS Code recommends me to do by a notification) 3. Restart the whole procedure... 4. Replace the statement "Class.forName("com.mysql.jdbc.Driver");" to "Class.forName("com.mysql.cj.jdbc.Driver");" (suggestion given by VS Code terminal) Hope it helps. 5. Or the main reason can be, you may not set the path for MySQL bin folder in either system variables or user variables.. The file hierarchy that must be running currently in VS code must be as follows: ProjectName { .vscode { settings.json } lib { } src { App.java } README.md "Debugger for java" must be installed, so that "Run Java" option will be visible to compile and run. Hope it works. ✨😀

  • @adonathomas1395
    @adonathomas13953 жыл бұрын

    I am having an issue. I installed MySQL Installer and added connector via library. But is is showing error "java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver" . But I can see it in libraries. I also deleted and added the library again.Do you have any idea how to solve this ?

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    I think you are running the program with "Run code" extension. You have to run program with "Run Java" that comes from Java Test runner and Project manager extensions. Hope you get it.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    May be: 1. You haven't imported the correct jar file (jdbc driver from MySQL Installation) 2. Try to clear the workspace cache in VS Code. (don't know how but sometimes VS Code recommends me to do by a notification) 3. Restart the whole procedure... 4. Replace the statement "Class.forName("com.mysql.jdbc.Driver");" to "Class.forName("com.mysql.cj.jdbc.Driver");" (suggestion given by VS Code terminal) Hope it helps. 5. Or the main reason can be, you may not set the path for MySQL bin folder in either system variables or user variables..

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Was your error resolved?

  • @shreyashdhane6234

    @shreyashdhane6234

    2 жыл бұрын

    @@harshith_takkala I had the same error, I tried "Run JAVA". it's working fine now😂 thanks, man.

  • @aayushsolanki2690
    @aayushsolanki26903 жыл бұрын

    showing error class not found java.lang.ClassNotFoundException: com.mysql.jdbc.Driver please help

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    May be: 1. You haven't imported the correct jar file (jdbc driver from MySQL Installation) 2. Try to clear the workspace cache in VS Code. (don't know how but sometimes VS Code recommends me to do by a notification) 3. Restart the whole procedure... 4. Replace the statement "Class.forName("com.mysql.jdbc.Driver");" to "Class.forName("com.mysql.cj.jdbc.Driver");" (suggestion given by VS Code terminal) Hope it helps.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Or the main reason can be, you may not set the path for MySQL bin folder in either system variables or user variables..

  • @EnzoLadriere
    @EnzoLadriere Жыл бұрын

    Hey ! Thanks for the tutorial but i have a question. Why its works with "Run java" and not with javac + java ?

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    It works, but we have to add some arguments in the command

  • @haveagreatday7051

    @haveagreatday7051

    Жыл бұрын

    @@harshith_takkala I also have this question. What arguments need to be added to the command?

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    We set class path, then compile, then run it. stackoverflow.com/questions/25186557/how-to-compile-mysql-jdbc-driver-with-a-java-file-in-cmd

  • @soueuoctavio4281
    @soueuoctavio42812 жыл бұрын

    call KZread translator I'm Brazilian. this was the Google translator who translated .Thank you

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    English ?

  • @soueuoctavio4281

    @soueuoctavio4281

    2 жыл бұрын

    Brazil .português

  • @Bhavana_Bora
    @Bhavana_Bora3 жыл бұрын

    I'm unable to locate these refrential libraries,Please help

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    When we create a java project, "JAVA PROJECT" named a world space is created. Under this space, there is a directory called "Referenced Libraries". It takes little bit time to create the workspace in VS code. If the work space is not created, then close the whole and open the java project again with VS code. Then after workspace creation has done, import the jar files.

  • @TheOnlyShubh
    @TheOnlyShubh2 жыл бұрын

    I am unable to find that ConnectorJ 3:42 after Installing MySql. Help Please

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    Then, please use MySQL installer that is already installed by the executable to download jar

  • @Hiebath
    @Hiebath3 жыл бұрын

    Broh I didn't got the file name javaprojects on the left side

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    It will come when you open VS code from projects root directory. Example: Projectname-> {src, lib, etc...}.

  • @supraja719
    @supraja7193 жыл бұрын

    Thank you so much for the vedio it is useful, and may i know how we can create a database of our own and also table

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Yes we can, I think you are ready with the MySQL. You can do that either by using command line client or Workbench.

  • @supraja719

    @supraja719

    3 жыл бұрын

    @@harshith_takkalayeah i got it Command : create database; 😅

  • @harshmavani24
    @harshmavani24 Жыл бұрын

    can you tell me please how to hide user credential or encrypt database connectivity root or password with help of . properties file

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    I too dont know May be you can search for that in maven repository and download the jar file and import it. Else, you can use a maven project setup to install automatically

  • @harshmavani24

    @harshmavani24

    Жыл бұрын

    @@harshith_takkala can you provide that repo ?

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    @@harshmavani24 yeah, just search maven central repository and you can get the maven configurations. You can also download jar files over there I guess.

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    @@harshmavani24 you can refer to my maven playlist where I made a simple maven project that contains setup of project jn vscode. There we can add our required configurations to download automatically with the help of xml loading.

  • @AryanKumar-vk1ex
    @AryanKumar-vk1ex22 күн бұрын

    in MYSQL connector file is not showing

  • @harshith_takkala

    @harshith_takkala

    21 күн бұрын

    @@AryanKumar-vk1ex if not there, then from mysql installer you have to install it. I guess you havent checked the checkbox in first time installation.

  • @krishraj7808
    @krishraj780821 күн бұрын

    Thanks a lot man 🤝. I was struggling in running this program for 4-5 hours. Don't know where to put the .jar file and getting an error every time. (❁´◡`❁)

  • @reemanfahaad
    @reemanfahaad Жыл бұрын

    what is the command for creating new database?

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    CREATE DATABASE You can refer to documentation or w3 schools for more information

  • @nagraj8949
    @nagraj89493 жыл бұрын

    Says unknown database. How to resolve this error

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    1. May be you dont have the database with the given name 2. May be do you have database with that name in the port running (3600)

  • @torrescle
    @torrescle3 жыл бұрын

    The vs code for Fedora 33 do not allow me to select any folder or .jar file :(

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    I dont have any idea about that operating system.

  • @jinside8279
    @jinside82792 жыл бұрын

    how to run this prject on browser

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    I think you are trying to combine the JSP, servlets and Mysql. If I am right, then i have a playlist. Please check it.

  • @deepakchauhn1512
    @deepakchauhn1512 Жыл бұрын

    i want that notepad file can you share

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    That's just for the reference buddy. It's just a boiler plate code for any JDBC programs in initial stages. You can find the same in online JDBS tutorials!

  • @vedgurnule
    @vedgurnule2 жыл бұрын

    I cannot find the Connector J folder even after installing twice

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    Not able to find J connector in MySQL installation ? I think you havent checked it while installation Just edit the installation using "installer-community"

  • @vedgurnule

    @vedgurnule

    2 жыл бұрын

    @@harshith_takkala I found it but it is in Program Files (x86) Folder Will that cause an issue?

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    @@vedgurnule no, it is right, MySQL stores some of its files there also

  • @vedgurnule

    @vedgurnule

    2 жыл бұрын

    @@harshith_takkala ok I thank you for the prompt reply

  • @nikhiljoshi9440
    @nikhiljoshi94403 жыл бұрын

    Showing error: Failed to launch debuggee in terminal. And asking to open launch.json

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Hey, my debugging is going fine, I have tried. This is how the launch.json must look similarly: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "java", "name": "Launch Current File", "request": "launch", "mainClass": "${file}" }, { "type": "java", "name": "Launch App", "request": "launch", "mainClass": "App", "projectName": "database_495139a9" } ] } This is for the jdbc code in App.java, where project name is "database". The "mainClass" attribute is created after you first run or debug the project. Hope it helps

  • @nikhiljoshi9440

    @nikhiljoshi9440

    3 жыл бұрын

    @@harshith_takkala I turned off Compatibility mode and now it's working. But when I am connecting mysql database to VSCode (not for jdbc) it's showing that couldn't find any database driver. Oracle MySql is already installed in my pc and I want to connect it to VSCode. I have also installed MySql Management tool in VSCode. The problem is that VSCode couldn't find mysql driver. I have tried my best and checked class path and online solution (Google and KZread) but all in vain. www.dropbox.com/s/8h713dirqax0f1v/2021-03-01-16-32-50.mp4?dl=0

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    @@nikhiljoshi9440 oh! I dont know that there is a concept of just connecting vs code with mysql. I will check into it. Thanks for the information 🙂

  • @nikhiljoshi9440

    @nikhiljoshi9440

    3 жыл бұрын

    @@harshith_takkala ok check the video I have mentioned in above comment.

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Yeah I got the video link in the notifications but not in the youtube comments.. Why like that I have seen your screen recording, and i will let u know soon. Edit: oh I got it thanks, I got it.🙂🙂 I have seen it and understood. But for this video I havent used any vs code extension specifically for mysql I will see that for sure, thanks for the video

  • @padhaiparcharcha
    @padhaiparcharcha3 жыл бұрын

    Can I download separate jdbc driver file?

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    You can download it if you are already installed with basic MySQL installation. You can run "MySQL installer- Community" and add Connector/J through which dependency will be downloaded into your MySQL installation. OR Visit this: dev.mysql.com/downloads/connector/j/ Choose archives, choose "platform independent" as the Operating system and there you get a ZIP file (and also TAR available). Unzip and you get the jar file.

  • @padhaiparcharcha

    @padhaiparcharcha

    3 жыл бұрын

    @@harshith_takkala in which folder I should add this jar file?

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    @@padhaiparcharcha just download the zip file, extract it and remember the location and then follow the same as I did from 07:27 ✌

  • @padhaiparcharcha

    @padhaiparcharcha

    3 жыл бұрын

    @@harshith_takkala how to enable options of refrenced library?

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    @@padhaiparcharcha in the "Java projects" named explored, you will find it. You have to open the VS code again from project root directory to see that.

  • @drxninja745
    @drxninja745 Жыл бұрын

    video was helpful, but lol u dont have to hide ur sql password, cuz no one can misuse it nor access it

  • @harshith_takkala

    @harshith_takkala

    Жыл бұрын

    ha locally its not possible, but if i deploy this project, it can be misused.

  • @princechoudhary4335
    @princechoudhary43352 жыл бұрын

    Are you from VIT?

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    Yeah, you too ?

  • @princechoudhary4335

    @princechoudhary4335

    2 жыл бұрын

    @@harshith_takkala yeah Your lab cat and labfat databases Lol😂

  • @harshith_takkala

    @harshith_takkala

    2 жыл бұрын

    @@princechoudhary4335 yeah bro 😅😅

  • @akramchaudhary4403
    @akramchaudhary44033 жыл бұрын

    Kya yr thoda Tezz bol leta bhai ghnta kuch sunai nhi de rha

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Ha bhai sure, Baat ye hai ki mere pass mic ka set nahi hei

  • @nishankpriydarshi5200
    @nishankpriydarshi52003 жыл бұрын

    record to dhang se kar lete bhai

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Ha bhai. Sorry for that. Ab se videos sahi honge

  • @nishankpriydarshi5200

    @nishankpriydarshi5200

    3 жыл бұрын

    @@harshith_takkala Nice 😀

  • @iam_a_sad_khan
    @iam_a_sad_khan3 жыл бұрын

    I am getting an error. java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver. Can you help me out?

  • @harshith_takkala

    @harshith_takkala

    3 жыл бұрын

    Please refer to the pinned comment.✌

  • @iam_a_sad_khan

    @iam_a_sad_khan

    3 жыл бұрын

    @@harshith_takkala Thanks, I was compiling with javac earlier and it was giving me this error but then I compiled it with the "run java" in vs code and it worked. Thanks again.

  • @kushalbarot4991

    @kushalbarot4991

    Жыл бұрын

    @@iam_a_sad_khan kaise kia bhai mujhe b smjao

Келесі