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

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 142

  • @harshith_takkala
    @harshith_takkala  3 ปีที่แล้ว +9

    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 5 หลายเดือนก่อน

      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
    @janhavipimplikar6048 2 ปีที่แล้ว +8

    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!

  • @kiaehe6292
    @kiaehe6292 3 ปีที่แล้ว +2

    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.

  • @ryansatriayudha
    @ryansatriayudha ปีที่แล้ว +1

    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.

  • @PrernaSharma-yl6ih
    @PrernaSharma-yl6ih 4 หลายเดือนก่อน

    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..

  • @harshith_takkala
    @harshith_takkala  4 ปีที่แล้ว +5

    Like if you find it useful. Cheers !!

  • @soueuoctavio4281
    @soueuoctavio4281 2 ปีที่แล้ว +1

    call TH-cam translator I'm Brazilian. this was the Google translator who translated .Thank you

  • @EnzoLadriere
    @EnzoLadriere ปีที่แล้ว +1

    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  ปีที่แล้ว +1

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

    • @haveagreatday7051
      @haveagreatday7051 ปีที่แล้ว +1

      @@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

  • @bagwanmohdhuzaif1263
    @bagwanmohdhuzaif1263 3 ปีที่แล้ว

    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

  • @akshattrivedi4164
    @akshattrivedi4164 5 หลายเดือนก่อน

    Great tutorial man 👍
    Still working after 2 years!!

  • @udaan878
    @udaan878 2 ปีที่แล้ว +2

    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.

  • @tinayetsinakwadi8906
    @tinayetsinakwadi8906 3 ปีที่แล้ว +5

    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 ปีที่แล้ว +2

      Thanks !! Check out my other videos too!!

  • @ommule4999
    @ommule4999 3 ปีที่แล้ว +1

    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  3 ปีที่แล้ว

      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. 🙂

  • @wagnerdds
    @wagnerdds 2 ปีที่แล้ว +1

    Thanks for your tutorial. It saved my life!

  • @joanmambwe3521
    @joanmambwe3521 2 หลายเดือนก่อน +1

    Hello, I'm having the error, 'java.sql.SQLException: Access denied for user 'USER'@'localhost' (using password: NO). How do i fix it?

    • @harshith_takkala
      @harshith_takkala  หลายเดือนก่อน

      I am not sure exactly, check the configurations of mysql, maybe something you missed

  • @arthurbttf
    @arthurbttf 2 ปีที่แล้ว

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

  • @crimson4706
    @crimson4706 ปีที่แล้ว +1

    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.

  • @adonathomas1395
    @adonathomas1395 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +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 ปีที่แล้ว +1

      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 3 ปีที่แล้ว +2

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

  • @husnajaved7514
    @husnajaved7514 3 ปีที่แล้ว +4

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      Thankyou ! Check out my other videos too !

  • @nisarg001
    @nisarg001 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

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

  • @parthjaiswal6151
    @parthjaiswal6151 3 ปีที่แล้ว +3

    nice learning from a fellow vitian

  • @AmanKumar-wu3ej
    @AmanKumar-wu3ej ปีที่แล้ว +1

    Thnaku bro you are life saver

  • @ZoomerApp
    @ZoomerApp 4 หลายเดือนก่อน

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

  • @TheOnlyShubh
    @TheOnlyShubh 2 ปีที่แล้ว +1

    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

  • @ИнкарЖолдыбай-ч9ж
    @ИнкарЖолдыбай-ч9ж หลายเดือนก่อน

    thank you so much

  • @iam_a_sad_khan
    @iam_a_sad_khan 3 ปีที่แล้ว +2

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      Please refer to the pinned comment.✌

    • @iam_a_sad_khan
      @iam_a_sad_khan 3 ปีที่แล้ว +2

      @@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 2 ปีที่แล้ว

      @@iam_a_sad_khan kaise kia bhai mujhe b smjao

  • @reemanfahaad
    @reemanfahaad 2 ปีที่แล้ว +1

    what is the command for creating new database?

    • @harshith_takkala
      @harshith_takkala  2 ปีที่แล้ว

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

  • @deliveryboy786
    @deliveryboy786 21 วันที่ผ่านมา

    mera java project wala option nhi aa rha hai vs code mai kya kru?

  • @aayushsolanki2690
    @aayushsolanki2690 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +2

      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 ปีที่แล้ว +3

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

  • @harshmavani24
    @harshmavani24 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      @@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.

  • @carladomingomiquel4744
    @carladomingomiquel4744 5 หลายเดือนก่อน

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

  • @raheenbagwan2240
    @raheenbagwan2240 2 ปีที่แล้ว +1

    Thank you so much

  • @AryanKumar-vk1ex
    @AryanKumar-vk1ex 3 หลายเดือนก่อน +1

    in MYSQL connector file is not showing

    • @harshith_takkala
      @harshith_takkala  3 หลายเดือนก่อน

      @@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.

  • @faithfillstories
    @faithfillstories 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

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

  • @torrescle
    @torrescle 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      I dont have any idea about that operating system.

  • @shivamseth2851
    @shivamseth2851 3 ปีที่แล้ว +1

    dhanyawad :-)

  • @LightWalk3r
    @LightWalk3r ปีที่แล้ว

    Thank you, this was super helpful

  • @krishraj7808
    @krishraj7808 3 หลายเดือนก่อน

    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. (❁´◡`❁)

  • @Bhavana_Bora
    @Bhavana_Bora 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      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.

  • @toriljain2711
    @toriljain2711 11 หลายเดือนก่อน

    thank you bhaiya

  • @supraja719
    @supraja719 3 ปีที่แล้ว

    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 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

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

  • @jinside8279
    @jinside8279 2 ปีที่แล้ว +1

    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.

  • @anmolverma2911
    @anmolverma2911 2 ปีที่แล้ว +2

    Thanks 🔥🔥🔥🚀👍

  • @abstylegaming
    @abstylegaming 2 ปีที่แล้ว

    Thanks bro Awesome Tutorial!

  • @deepakchauhn1512
    @deepakchauhn1512 2 ปีที่แล้ว +1

    i want that notepad file can you share

    • @harshith_takkala
      @harshith_takkala  2 ปีที่แล้ว

      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!

  • @padhaiparcharcha
    @padhaiparcharcha 3 ปีที่แล้ว +1

    Can I download separate jdbc driver file?

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

      @@harshith_takkala how to enable options of refrenced library?

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      @@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.

  • @yugansh4356
    @yugansh4356 3 ปีที่แล้ว +1

    Thank you so much you deserve much subscriber

  • @vedgurnule
    @vedgurnule 2 ปีที่แล้ว +1

    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 ปีที่แล้ว +1

      @@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

  • @yunusshaikh7478
    @yunusshaikh7478 3 ปีที่แล้ว

    thank you so much . It really helped me

  • @nikhiljoshi9440
    @nikhiljoshi9440 3 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      @@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 TH-cam) but all in vain.
      www.dropbox.com/s/8h713dirqax0f1v/2021-03-01-16-32-50.mp4?dl=0

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      @@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 ปีที่แล้ว +1

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

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +2

      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

  • @nitigyajoshi4658
    @nitigyajoshi4658 3 ปีที่แล้ว

    thanks a lot sir

  • @t.a.f.6736
    @t.a.f.6736 3 ปีที่แล้ว

    Thank you!

  • @OsomWay
    @OsomWay 3 ปีที่แล้ว

    You are a monster. Thank you bro!

  • @princechoudhary4335
    @princechoudhary4335 2 ปีที่แล้ว +1

    Are you from VIT?

  • @ahmadshodikin262
    @ahmadshodikin262 2 ปีที่แล้ว +1

    thanks, it really help :)

  • @vidyatrimbake480
    @vidyatrimbake480 ปีที่แล้ว

    Great!!🌻

  • @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.

  • @hilmanaziz
    @hilmanaziz 3 ปีที่แล้ว

    another great video

  • @akramchaudhary4403
    @akramchaudhary4403 3 ปีที่แล้ว

    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
    @nishankpriydarshi5200 3 ปีที่แล้ว

    record to dhang se kar lete bhai

  • @nagraj8949
    @nagraj8949 3 ปีที่แล้ว +1

    Says unknown database. How to resolve this error

    • @harshith_takkala
      @harshith_takkala  3 ปีที่แล้ว +1

      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)

  • @tejasbele1456
    @tejasbele1456 3 ปีที่แล้ว +1

    Thank you so much...