List:MySQL and Java« Previous MessageNext Message »
From:Jeff Newmiller Date:March 14 2003 2:45am
Subject:Re: help for my jdbc connection problem
View as plain text  
On Fri, 14 Mar 2003, Liqiu.Tan wrote:

> Hi,
> 
> My system is Redhat 8.0 + Java 1.4.0.3 + Mysql 3.23.55.
> My /etc/hosts file is :
> "127.0.0.1       localhost       localhost
>  192.168.0.14    hy
> "
> also ,192.168.0.14 is the ip address of localhost.
> 
> if my connection  url is  "jdbc:mysql://192.168.0.14:3306/data"  it works
> fine.
> if my connection  changed to "jdbc:mysql://localhost:3306/data" or
> "jdbc:mysql://127.0.0.1:3306/data" , it throws the following error:
> "
> java.sql.SQLException: Server configuration denies access to data source
>         at org.gjt.mm.mysql.MysqlIO.init(Unknown Source)
>         at org.gjt.mm.mysql.Connection.connectionInit(Unknown Source)
>         at org.gjt.mm.mysql.jdbc2.Connection.connectionInit(Unknown Source)
>         at org.gjt.mm.mysql.Driver.connect(Unknown Source)
>         at java.sql.DriverManager.getConnection(DriverManager.java:512)
>         at java.sql.DriverManager.getConnection(DriverManager.java:171)
>         at JdbcTest24.main(JdbcTest24.java:11)
> "
> 
> What is my problem?  Thanks.

a) your hosts file shouldn't have "localhost" twice:

     127.0.0.1     localhost
     192.168.0.14  hy hy.localnet

   where "localnet" is a name for your local network defined in
   /etc/network:

     localnet 192.168.0.0

   and in /etc/resolv.conf:

     search localnet

   should be included so it won't try to look for "hy" in a different
   domain, and in /etc/nsswitch.conf:

     hosts:          files dns

   so it will consult the hosts file before trying dns.

   Note that "localnet" can and probably ought to be used
   literally... that is, don't put in "joe.com" because you don't manage
   "joe.com".  If you did use "joe.com" you might find that there is
   a real "joe.com" that you won't be able to reach anymore. There is no
   public top level domain "localnet" for you to get in trouble with, so
   you can manage it yourself for your private network.

b) Read http://www.mysql.com/doc/en/Access_denied.html, in particular note
   that every username includes a host name that must resolve to an ip
   address, or just a plain ip address.  If you want to connect using
   both "localhost" and "hy", you must create two users... one
   "user@localhost" and one "user@hy".

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

c) don't forget to check the above URLs.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@stripped>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------

Thread
help for my jdbc connection problemLiqiu.Tan14 Mar
  • Re: help for my jdbc connection problemJeff Newmiller14 Mar
    • help for my jdbc connectionShivani17 Mar
      • Re: help for my jdbc connectionMax Morawski17 Mar
  • Re: help for my jdbc connection problemPål Arne Hoff14 Mar