MySQL & jdbc

Roberto Nunnari nunnari at die.supsi.ch
Mon May 12 04:03:31 PDT 2003


if this doesn't work:

# mysql -u username -p yourdbname

then check your mysql user table:
 > use mysql;
 > select host, user, password from user;

you should have an entry for username at localhost with password

Anyways, in my java code I use:

getConnection( "jdbc:mysql://localhost/mydbname", "myusername", "mypassword" );

regards.

Anselme wrote:
> Hi everybody !
> 
> I've got a little problem trying to get access to MySQL with a java
> application.
> 
> I use :
> mysql 3.23.55
> linux-sun-jdk1.3.1.07_1
> mysql-jdbc-mm
> FreeBSD 4.7-STABLE
> 
> I got the connection with MySQL vi jdbc without problem but i can't
> access the database as the user  ...
> I got the following from the server :
> 
> #java.sql.SQLException: Invalid authorization specification: Access
> denied for user: 'user_name at localhost.mydomain.com' (Using password:
> YES)
> 
> 
> The rights in MySQL sounds good because when I try to access by the
> console, it's all fine.
> 
> In the java program, I have the following code :
>  dbcxn =
> DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name?user=user_name&password=user_pwd")
> 
> I also tryed with :
> dbcxn =
> DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name","user_name","user_pwd");
> 
> Any Ideas ?
> 
> Thanks 
> 


-- 
               Roberto Nunnari -software engineer-
                 mailto:nunnari at die.supsi.ch
  Scuola Universitaria Professionale della Svizzera Italiana
            Dipartimento di Informatica e Elettronica
                   http://www.die.supsi.ch
  SUPSI-DIE
  Via Cantonale                        tel: +41-91-6108561
  6928 Manno                 """       fax: +41-91-6108570
  Switzerland               (o o)
=======================oOO==(_)==OOo========================



More information about the freebsd-database mailing list