Hi,

i tried searching through the net for help, but could not find an answer.
Could anyone out there please help?

i'm running the mysql server on a redhat linux 7.0, kernel
2.2.16-22enterprise on a 2-processor i686.
I've been trying to connect to a database but i keep getting the access
denied error. I've logged in sucessfully using
the exact userid and password at the mysql console, so my grant tables are
definitly set correctly.

this is my code:

import java.sql.*;
import java.util.*;

public class Connected {
        public static void main (String[] args) throws Exception{
                Connection con = null;

                try{
                  String url = "jdbc:mysql://localhost:3306/mydatabase";
                        Statement stmt;
                        ResultSet rs;
                        Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                  System.out.println("Class.forName");

                  con = DriverManager.getConnection(url,"root","mypasswd");
                        stmt = con.createStatement();
                }
                catch(SQLException e) {
                        System.out.println("Unable to load driver.");
                        e.printStackTrace();
                }
                finally{
                        if (con != null){
                                try{con.close();}
                        catch (Exception e){}
                      }
                }
        }
}

my dir structure in linux is as such:
mysql dir -- /usr/local/mysql
mmmysql dir -- /usr/local/mysql/mmmysql
source code resides in -- /usr/local/mysql
source code able to be complied, but when run, gives the error:

Unable to load driver.
java.sql.SQLException: Invalid authorization specification:
Access denied for user:'[EMAIL PROTECTED]'( Using password: YES)
        at org.gjt.mm.mysql.MysqlIO.init(MysqlIO.java:330)
        at org.gjt.mm.mysql.Connection.connectionInit(Connection.java:261)
        at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Connection.java:89)
        at org.gjt.mm.mysql.Driver.connect(Driver.java:167)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:177)
        at Connected.main(Connected.java:16)

thks
shane


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to