Accessing MYSQL Database Using Java in Eclipse IDE

Posted by: Admin  :  Category: Mysql

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

This tutorial will show you how to use Java to query a MySQL database using the Eclipse IDE.

Linux Cpanel shared hosting: 600 GB disk space, 6 TB bandwidth, free domain, unlimited databases and ftp accounts, web hosting cheap and pro at Hostony

25 Responses to “Accessing MYSQL Database Using Java in Eclipse IDE”

  1. oharinth Says:

    thank you, your explanation was very helpful.

  2. iceman11a Says:

    I just tryied your sample from your video and it works real good. The project I’m working is a Web Site. and I wanted to add some kind of edit page in java that can get values from a database and display them in a forum and then let the user make changes to it and then update the database. So far I haven’t fount a sample even close to what I’m looking for.

  3. iceman11a Says:

    Cool Video. Do you have plans for making a Video to show how to use forms in Java. and accessing a mysql database, I been looking for samples and haven’t fount any thing that I can use.

  4. TheGydriy Says:

    @TheGydriy Problem was in wrong importing of java.sql.*;

  5. TheGydriy Says:

    In the line: PreparedStatement statement = con.prepareStatement(“select * from empl”);
    I’ve got type mismatch exception –
    cannot convert from java.sql.PreparedStatement to com.mysql.jdbc.PreparedStatement
    What am I doing wrong?

  6. BPBloodeye Says:

    @Milaad I did get mine working, can’t really remember the issue precisely though. One thing I had to do was go to my CPanel and go to Remote Database Access Hosts, and enable the wildcard ‘%’ which allows connections from any IP. 

  7. Milaad Says:

    @Milaad NVM, I got it, change to
    Connection con = DriverManager.getConnection(“jdbc:mysql://localhost/testdb”,”root”,””);
    Instead! Much easier!

  8. Milaad Says:

    @BPBloodeye I have the same problem, did you get what the problem is? I really need some help!

  9. MarkusGamers Says:

    Now im getting this??
    Code: ht tp://pastebin(.)com/Jm0H5cTm
    Error: ht tp://pastebin(.)com/8stSW3Fg

    Note: Remove () and space in the URL

  10. MarkusGamers Says:

    Here is the code i get error on!
    ht tp://pastebin(.)com/j82MW2tC
    PLEASE HELP ME!!!

  11. MarkusGamers Says:

    Here is my code.
    public class Main
    {

    public static void main(String[] args) throws Exception
    {
    Class.forName(“com.mysql.jdbc.Driver”);

    Connection con = DriverManager.getConnection(“j-dbc:mysql://localhost:3306/Login System”,”root”,””);
    PreparedStatement statement = con.prepareStatement(“select * from `Login System` `name`”);
    ResultSet result = statement.executeQuery();

    while(result.next())
    {
    System.out.println(result.getString(1) + ” ” + result.getString(2));
    }
    }
    }

  12. MarkusGamers Says:

    I get this:
    Exception in thread “main” java.sql.SQLException: No suitable driver found for j-dbc:mysql://localhost:3306/Login System
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Main.main(Main.java:14)

    PLEASE HELP!!!
    I NEED HELP!!!

  13. 1Pkor Says:

    Excellent 🙂

  14. sheerqueer11 Says:

    Thanks a Tonne..
    

  15. BPBloodeye Says:

    Having issues connecting to an DB on a server. I have replaced localhost:2082/ with my web address and port number, and added in my database, username and password and many errors are received. I just need to know if I’m attempting to connect correctly.

    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

  16. Theprashanth549 Says:

    Thanks a lot.

  17. ado271ado Says:

    This video helped me to,
    thanks a lot,
    nice job.

  18. carlisle21yaps Says:

    @fatstylers89 thanks!!!!!! it worked already!!!!

  19. da1gt Says:

    well well man! 

  20. fatstylers89 Says:

    @carlisle21yaps check this line :
    Connection con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/visitor”,”root”,”root”);

    you need to change to this:
    Connection con = DriverManager.getConnection(“jdbc:mysql://localhost:3306/visitor”,”root”,””);

  21. carlisle21yaps Says:

    okay i got it!!! it’s the password thing that brought glitch to my prog! thanks so much!!!!!!!!!!!!!!!! this video helped me a lot!!!!!!!!!!!! omg to the max! you’re the best!!

  22. carlisle21yaps Says:

    this came out:
    Exception in thread “main” java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password: YES)

    and there is still some sub-problems in it like sqlerror.java:1073,
    mysqlIO.java:3597….

    help pls…

  23. carlisle21yaps Says:

    this came out:
    Exception in thread “main” java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password: YES)

    and there is still some sub-problems in it like sqlerror.java:1073,
    mtsqlIO.java:3597….

    help pls…

  24. carlisle21yaps Says:

    @fatstylers89 I have the same problem!

  25. mhra091992 Says:

    I run this but I got an error message:

    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.

    I’ve no idea how to troubleshoot this 🙁

Leave a Reply

*