I am consolidating all the responses back and forth and putting it back out
to the mysql list since it is still not resolved....shucks.

TIA...Jim

Here is the complete error and the connection code.

java.net.UnknownHostException:  127.0.0.1
        at java.net.InetAddress.getAllByName0(InetAddress.java:571)
        at java.net.InetAddress.getAllByName0(InetAddress.java:540)
        at java.net.InetAddress.getByName(InetAddress.java:449)
        at java.net.Socket.<init>(Socket.java:100)
        at org.gjt.mm.mysql.MysqlIO.<init>(MysqlIO.java:114)
        at org.gjt.mm.mysql.Connection.<init>(Connection.java:229)
        at org.gjt.mm.mysql.Driver.connect(Driver.java:126)
        at java.sql.DriverManager.getConnection(DriverManager.java:517)
        at java.sql.DriverManager.getConnection(DriverManager.java:199)
        at TestApp.getConnection(TestApp.java:32)
        at TestApp.displayDatabaseValues(TestApp.java:40)
        at TestApp.main(TestApp.java:72)
java.sql.SQLException: Cannot connect to MySQL server on  127.0.0.1:3306. Is
there a MySQL server running on the machine/port you are trying to connect
to? (java.net.UnknownHostException)

   protected static Connection getConnection() throws Exception
    {
        Class.forName("org.gjt.mm.mysql.Driver");

        String host = "127.0.0.1";
        String dbPort = "3306";
        String db = "SITESTATS";
        String url = "jdbc:mysql:// " + host + ":" + dbPort + "/" + db;

        return DriverManager.getConnection(url);
    }


I can ping 127.0.0.1, localhost, the host name and it's IP address.  As
stated before this is a working DB with like data accessible via perl and
DBI/DBD.

I do not have a username and apssword associated with this connect at this
time and haven't tried that (yet) because the error seems to indicate it is
not the problem....but what do I know.


----- Original Message -----
From: "Bombardier Systems Consulting" <[EMAIL PROTECTED]>
To: "Johan Andersson" <[EMAIL PROTECTED]>
Sent: Tuesday, June 05, 2001 1:50 PM
Subject: Re: Host resolving (was: Re: JDBC - UnknownHostException)


> I am currently running all of this on one machine.  After I get the JDBC
> working I want to hook it into java serving web pages but that is later.
I
> currently have perl and mysql serving web pages both on the same machine
and
> from any system within my LAN...so it is working (and I think the "it" is
> TCP/IP).
>
> So should I be using localhost, 127.0.0.1, the host name or the host IP
> address?  AND should I be using 3306 or 1285 as port numbers?
>
> My "host name".err file in my /var/lib/mysql seems to be working just fine
> and it is not reporting the errors that I am getting from Java.  I
> personally don't think this is a mysql problem.  I think it is between
JDBC
> and java on RH7.1.
>
> The search continues....
>
> TIA
>
> Jim
> ----- Original Message -----
> From: "Johan Andersson" <[EMAIL PROTECTED]>
> To: "Bombardier Systems Consulting" <[EMAIL PROTECTED]>
> Sent: Tuesday, June 05, 2001 11:04 AM
> Subject: Re: Host resolving (was: Re: JDBC - UnknownHostException)
>
>
> Okey.. but what is the scenario here..
>
> You got 1 workstation where you are running the java app which gets
> the unknownhostexception, and a mysqld running on another machine?
>
> Or is the mysqld running on the same machine as the java app ?
>
> The nsswitch.conf sets the order of different lookups. You can from
> that file decide whether host lookups should be done first by the
/etc/hosts
> file, 2nd from a NIS server and 3rd by DNS (/etc/resolv.conf)..
> If you only specify the hosts file, lookups that matches records in your
> hosts file will be successful.
>
> I cannot remember the actual format of this file, but it is quite
> self-explaining.
>
> Some things about mysql:
> If you can connect with the mysql client from the server itself, but not
> from
> any other machines, you may have disabled TCP/IP support. Then only unix
> sockets
> are supported (localhost/127.0.0.1 is wrapped to use unix sockets instead
of
> tcp/ip)
>
> If you can't see the mysqld in the LISTENING list of the command
> netstat -na, it can
> depend on the socket support described above. It can also be a problem
with
> the mysqld.
> Look at the file path/fqdn.err, where path is the datadir of your mysqld
and
> fqdn
> the Fully-Qualified-Domain-Name which should be the same as the result of
> executing
> the hostname command in the console.
>
>
> R,
> Johan.
>
>
> ----- Original Message -----
> From: "Bombardier Systems Consulting" <[EMAIL PROTECTED]>
> To: "Johan Andersson" <[EMAIL PROTECTED]>
> Sent: Tuesday, June 05, 2001 7:31 PM
> Subject: Re: Host resolving (was: Re: JDBC - UnknownHostException)
>
>
> > I missed your response it my initial review of messages and already
> > responded to others with full error and connection code.  I am using NAT
> for
> > this system so the /etc/resolv.conf show the domain name and the DNS
> server
> > IP addresses that seem to work fine ( I can FTP and surf the Internet
and
> > print through my NT server).  I am looking at the /etc/nsswitch.conf and
> > don't know what is "correct"...there is a lot of "nisplus" everywhere.
> > When I ran the netstat -na I did not show a listening socket on TCP port
> > 3306 (it has 3306 in the mysql_config) BUT did show a listening 1285 for
> > /var/lib/mysql/mysql.sock   ????  I just changed the TestApp.java
> parameters
> > to that, compiled and ran it and get the same error.
> >
> > I would like to know why this 1285 is linked to mysql and 3306 is
> > not...curious
> >
> > TIA
> >
> > Jim
> >
> >
> > ----- Original Message -----
> > From: "Johan Andersson" <[EMAIL PROTECTED]>
> > To: "Bombardier Systems Consulting" <[EMAIL PROTECTED]>
> > Sent: Tuesday, June 05, 2001 4:44 AM
> > Subject: OT: Host resolving (was: Re: JDBC - UnknownHostException)
> >
> >
> > Doublecheck with netstat -na on the server to see if there is a
listening
> > socket on TCP port 3306..
> > (but you said it did work to connect on other machines ?)
> >
> > I think that particular machine has problems with its hostname lookup..
> > If its a redhat machine too, check with /etc/resolv.conf and
> > /etc/nsswitch.conf to see if they're correct.
> > (Are you able to do other lookups on that machine?)
> >
> >
> > R,
> > Johan Andersson
> > Consultant, Qbranch
> >
> > ----- Original Message -----
> > From: "Bombardier Systems Consulting" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, June 05, 2001 10:41 AM
> > Subject: JDBC - UnknownHostException
> >
> >
> > > Hello,
> > >
> > > I am running RedHat=7.1, MySQL= 3.23.36, JDBC = mm.mysql-2.0.4 and
Java
> > > =1.3.1.
> > >
> > > I am trying to open MySQL through the JDBC driver and get the
> > > java.net.UnknownHostException error...this is all on one machine
> > >
> > > I have used the MySQL db with perl and it seems fine.  I have tried
> > > "localhost, 127.0.0.1, the host name and the "real" IP address in the
> > "host"
> > > part of the URL to no avail.  I do have port 3306 in the URL and have
> > > checked the mysql config file to make sure it agrees...so there seems
to
> > be
> > > a MySQL server running on the machine/port that I am trying to connect
> > > to....BUT  java.net.InetAddress.getAllByName0.java:571  throws the
> > > exception.
> > >
> > > I have now gone through the archives and can't find a similar
> > > problem...RedHat has fixed the localhost.localdomain problem in 7.1.
> > >
> > > What am I missing?
> > > TIA
> > >
> > > Jim
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > >
> > >
> >
> >
> >
> >
>
>
>


---------------------------------------------------------------------
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