Results 1 to 4 of 4
  1. #1
    mitty is offline Member
    Join Date
    Jan 2010
    Rep Power

    Default Connecting a MySQL DB through Eclipse

    Hi Guys. I'm a complete beginner using Java.

    I've created a database called NLP_test with a table called customer

    im using Eclipse to try connecting to the DB with the following code

    (p.s i've looked around the net and compiled this from bits and bobs to try but had no joy.)

    import java.sql.*;
    import javax.sql.*;

    public class JDBCDemo

    String Url = "jdbc:mysql://localhost:3306/NLP_test";
    String Class = "com.mysql.jdbc.Driver";
    String username = "root"
    String password = "k6cbzq4qw2"

    try {

    connectionObject = DriverManager.getConnection ("com.mysql.jdbc.Driver","root","k6cbzq4qw2");
    StatementObject = con.createStatement();

    catch (Exception e)
    System.err.println("problems connecting to " + Url);

    im getting the following error...

    java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)
    at com.mysql.jdbc.SQLError.createSQLException(SQLErro
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3563)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3495)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:919)
    at com.mysql.jdbc.MysqlIO.secureAuth411( 4001)
    at com.mysql.jdbc.MysqlIO.doHandshake( 84)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connect
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance( 6)
    at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at jdbcdemo.main(

    thanks in advance guys

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    Try the String "" instead of "localhost".

    kind regards,


  3. #3
    mitty is offline Member
    Join Date
    Jan 2010
    Rep Power


    I tried changing localhost but it didnt work. the same error is showing still.

    anyone else have any ideas?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    You've defined a bunch of strings at the top for your url, classname and login stuff, yet you don't use them. More importantly, look at the url you have passed into getConnection().

Similar Threads

  1. Connector J with Eclipse and MySQL 5.0.x
    By int80 in forum Eclipse
    Replies: 11
    Last Post: 05-31-2010, 10:32 AM
  2. Eclipse / Mysql problem
    By jdevm in forum Eclipse
    Replies: 0
    Last Post: 10-09-2008, 02:16 AM
  3. hello the community & mysql connecting problems
    By scchia in forum New To Java
    Replies: 6
    Last Post: 07-16-2008, 09:49 AM
  4. problem in connecting to mysql database
    By nancyv in forum Java Servlet
    Replies: 6
    Last Post: 04-02-2008, 12:33 PM
  5. connecting to mysql database
    By javagal in forum NetBeans
    Replies: 2
    Last Post: 08-04-2007, 01:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts