Java Video Tutorial 34

[ad_1]
Get the Code & Installation Instructions:

In this part of the Java Video Tutorial I show you how to setup Java JDBC in Eclipse.

I then cover how to connect to a MySQL database, query it and get the results of a query. We also look at the Exceptions you’ll need and much more.


Posted

in

by

Tags:

Comments

31 responses to “Java Video Tutorial 34”

  1. Vishwadeep Singh Avatar

    Hey Derek, I've been having this problem with my Java class and SQL database for the past week and I can't seem to get over it. I've followed the steps you've layed out on your website and I've also watched this exact video several times. I still can't get over my problem. The issue that is coming up in my console in eclipse is as follow:

    SQLException: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    VendorError: 0

  2. Mr Arclight Avatar

    Hello Derek, I have question, could you please tell me, I am learning whole java series and this video with SQL just ripped me into pieces, I don't have any idea what I am doing. I installed mySQL, added jar to eclipse path but I still don't know how to handle it, my main doesn't want to compile.
    Could you please tell me, where should I go, which of your videos covers SQL from total beginnings. I have seen that you have SQL tutorial (6 videos, but from 2010 year, so I wonder if its still good to learn) and PHP tutorial which contains from 14th to 18th lesson infrormations about SQL.
    Can you enlighten way for me? Just where is best place to start with sql 🙂
    Thanks a lot for everything again, I am learning a lot!

  3. Yonatan Bitton Avatar

    Is it mandatory to download & install MySQL as well before installing the connector ?
    Thanks 🙂

  4. Irfan Sindhi Avatar

    Derek, do I have to install the jdbc driver on our client machine or on my remote server(if i have one) to run my java-sql codes? If the driver had to be installed on the client side that wouldn't be so good for people trying to access my database. Sorry if it was a stupid question.

  5. Michéal king Avatar

    Keep getting an error under (selectStuff);

  6. John Galew Avatar

    How did you add mysql jar file to a folder in System? I can't do that,it says i don't have access

  7. Youssef Samwel Avatar

    Derek, what does Class.forName do

  8. Simran Singh Avatar

    Need help Derek! Where did you get this sql terminal from? I can do that in CMD in windows. is there any particular software like eclipse or should i keep using CMD?

  9. Hector Toscano Avatar

    How can I insert data to a MySQL database from Java code?

  10. Gump Avatar

    Can you do one of these for MongoDB please?

  11. Prince Sonu Avatar

    hi derek again i need some help with sql intrigation with the windows for some reasonn i m unable to connect import java.sql.*;

    below i m posting my code … i m not sure about user name or pass either i did every step u said in the vid … can u either do a detailed video for how to do connection on windows or explain to me how should i fix my error please a quick response will do me wonders i m kinda stuck here at this point… i have searched online alot but have no help far

    below is error i get
    "SQLException :Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    VEndeor error : 0
    "

    public class JavaLesson34{
    public static void main(String[]args){
    Connection conn = null;
    try{
    Class.forName("com.mysql.jdbc.Driver");
    conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/customers1","username","pass" );
    Statement sqlState = conn.createStatement() ;
    String selectStuff = "Select first_name from customers1";
    ResultSet rows = sqlState.executeQuery(selectStuff);
    while(rows.next()){
    System.out.println(rows.getString("first_name"));

    }
    }catch(SQLException ex){
    System.out.println("SQLException :" +ex.getMessage());
    System.out.println("VEndeor erroe : " +ex.getErrorCode());
    }catch(ClassNotFoundException e){
    e.printStackTrace();
    }

    }
    }

  12. Mountain Liu Avatar

    i cant not mv or cp my .jar file to /System/Library/Java/Extension . i try to use command line , but it said operation not permitted

  13. Przemysław Latoch Avatar

    Hey, I have a problem with adding it on my computer. In my intellij i added it to one project and when i am opening different there is no mysql library. I don't know how to add it properly on windows so that every project could use it. How should i do that? To which file shoud i put it? Or maybe it is normal and I have to add it every time i want to use it?
    Thanks for help

  14. Ευάγγελος Κριεζής Avatar

    Hi Derek,
    first of all thank you for your tutorials but if it's possible, how about a jpa tutorial? It will be great help!!!!!!!!!!!

  15. Damilola Olagundoye Avatar

    how do you do this on windows. 90% of people use windows. can someone please help. the commands are different on windows.

  16. Lester Avatar

    Hi + Derek Banas
    In my opinion, we should have a finally statement which tries to close the connection to avoid possible connection errors.

  17. N.M. Owen Avatar

    Am I mistaken (I could be, I watch these things at like 4am) that at the outset you said you were going to provide a third, PC-specific way to install the relevant library, but then as soon as you had shown the "build path"/Eclipse way you moved on to the terminal interface/MySQL stuff?

    I am (regretfully) on a PC laptop from work.  JAR files are Mac-specific, no?  When I did the download mentioned at the beginning, I didn't get a folder with a JAR file in it (among other things) but rather just a single installer file.

    Thanks Derek!

  18. Ivan Mah Avatar

    I'm sorry to bother you but i got a problem. I been trying to solve this bug for a month and i still can solve it. 

    Most of the code is from this video. I got this error:

    SQLException: Communications link failure

    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    VendorError: 0

    mySQL-connector-java-version-bin.jar is at referenced Libraries. I can't get it to go to JRE System Library. 

    I  try changing my localhost to my ipAddress and add the :3306(port 3306) to it but fail

    i need help. Im still new to this

  19. sudheer p Avatar

    how to download and connect to oracle sql database on mac???

  20. SKtheGEEK Avatar

    so how can i create a database from java . how to do all the other operation . you just told how to access a created database .

  21. SKtheGEEK Avatar

    can you please explain the line Class.forName("com.mysql.jdbc.Driver");
    what does this actually do ??  and will i have to write the same in my program or it will be different for my system ?

    i got a error – java.lang.ClassNotFoundException .

    please help .

  22. SKtheGEEK Avatar

    where the databases are actually saved inside my system ?

  23. Styles P'yall Avatar

    Hey Derek long time no see :D. I only log in with a password. What do I do then?

  24. Vincent Poon Avatar

    Hi Derek, thanks for sharing this video, so that we know how to use Java to collect to MySql. However, we have to create some tables in the DB before we can do so? If I want to collect data by using Java and then input to the MySql DB, is it possible? Or again, I need to create tables first? Thanks. Vincent.

  25. Madalina Laios Avatar

    Hi Derek . I added the jar file only in Eclipse, at a project(in the libraries) and now i have the Referenced Librarie packet. My question is: do i have to add in every project the jar file so i can use it ? Thanks 🙂

  26. Ruchi Sethi Avatar

    Thanks a ton! You are a great teacher. And the best thing about your videos is that there is no nonsense talk and they all are pretty fast paced. Wish I would be as fast and good as you are with your logics and understanding of java libraries.

    Regards

  27. Waseem Swaileh Avatar

    Dear Derek .. thank you for your efforts on this great tutorials … I think I have a problem with learning programming … I have no program experience and my University degree has nothing to do with computer .. yet I think I did an excellent job tell this point … I really need you to help me sir … the point is … I start learning java because I would like to learn android programming .. and I have heard that .. any one should have java programming experience in order to learn java … but I think I am missing a lot here .. what skills should I have to know and master in order to become an expert programmer ???? .. I was thinking to go to college again and learn computer science … Please help me I am very disappointed .. 🙁

  28. invinciblekd Avatar

    Hi Derek, gr8 tutorials, learning a lot ! BTW do I need to install MYSQL before ? I mean here I see that you have this MYSQL Prompt opened, I am just wondering how to access it on windows !
    Thanks

  29. Hadi Mohammadzadeh Avatar

    Many thanks for your video. for people who have windows the following link would be useful:
    http://stackoverflow.com/questions/18894416/install-mysql-jdbc-driver-msi

  30. ThinkPositive00 Avatar

    Now that is just neat. Opens many doors.

  31. Derek Banas Avatar

    I'm glad I could help. You're very welcome 🙂 My laptop is 100% Ubuntu. If they made a replacement for iMovie I'd go Ubuntu instead of Windows and OSX

Leave a Reply

Your email address will not be published. Required fields are marked *