Results 1 to 2 of 2

Thread: access denied??

  1. #1
    handry is offline Member
    Join Date
    Dec 2011
    Posts
    2
    Rep Power
    0

    Default access denied??

    I want to ask why the program that I run a message
    "access denied for user @ localhost (using password no)"

    The following coding that I made, maybe if there was an error
    public void connect () {
    try {
    Class.forName ("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection ("jdbc: mysql: / / localhost: 3306/akademik ","","");
    cn = conn.createStatement ();
    } catch (Exception e) {
    JOptionPane.showMessageDialog (null, "connection failed ..");
    System.out.println (e.getMessage ());
    }
    }
    public void cariuser () {
    try {
    connection ();
    String sql = "Select * from user where username = '" + jTextField1.getText ()+"' and password =' "+ jTextField2.getText () +" '";
    ResultSet rs = cn.executeQuery (sql);
    if (rs.next ())
    {
    JOptionPane.showMessageDialog (null, "Success Bro .....!");
    NewJFrame1 new (). show ();
    this.dispose ();
    }
    } catch (Exception e) {
    JOptionPane.showMessageDialog (null, "There is a mistake");
    }

    oh .. yes i also want to ask about conn = DriverManager.getConnection
    coding that works for what?
    and ("jdbc: mysql: / / localhost: 3306 ...");
    can change kah? if you can, we must replace it with what?
    note:
    I made a program using java and its database mysql

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    19

    Default Re: access denied??

    Use e.printStackTrace() in your exception handlers (the catch blocks) so you can at least see where the exception is being thrown.

    It looks, though, like your MySQL is not accepting connections.

Similar Threads

  1. Access Denied!@#
    By PhQ in forum New To Java
    Replies: 8
    Last Post: 09-21-2011, 05:06 PM
  2. ClassLoader Access denied
    By Dennis in forum Advanced Java
    Replies: 0
    Last Post: 04-24-2011, 01:58 PM
  3. newbie here, access denied error?!?
    By kingpabs in forum JCreator
    Replies: 3
    Last Post: 04-01-2011, 02:16 AM
  4. Access is denied
    By tholland in forum New To Java
    Replies: 2
    Last Post: 12-20-2010, 08:57 PM
  5. access denied
    By Dennis in forum Advanced Java
    Replies: 8
    Last Post: 06-05-2010, 08:46 AM

Posting Permissions

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