Обсуждение: No DB connection in Netscape ? Please help.

Поиск
Список
Период
Сортировка

No DB connection in Netscape ? Please help.

От
"Kapoor, Nishikant X"
Дата:
Hello friends

I have apache-1.1.3-3 and PostgreSQL-6.3.2 running on my Linux RH4.2,
kernel 2.0.30 (genx). I have a Java Applet that tries to connect to
PostgreSQL
using JDBC, from NS-4.5b1 on an IBM RISC6000, AIX-4.1.4 (mm01).

Typing "mm01: netscape http://genx/PrfApplet.htm" brings up the applet
in the NS
but the database connection is not established. The Java console shows:

openDb(PrfDb):Connecting to Database URL = jdbc:postgresql:prfdb...
openDb(PrfDb): Could not connect. e= security.Couldn't connect to
'localhost' with origin from 'genx'.

The same problems exits when I start NS from the same machine where the
PostgreSQL
server is running i.e. the Linux box(genx).

*** But, when I use "genx: netscape http://127.0.0.1/PrfApplet.htm" on
genx, the
*** database connection gets established.

The two machines genx and mm01 are on the same network and can ping each
other
using the hostnames.

THE CLASSPATH IS *NOT* SET ON RISC MACHINE (mm01) and the postgresql.jar
is already
in mm01:$MOZILLA_HOME/java/classes. The JDBC interface is as follows:

    // Load the driver
    try {
      Class.forName(PrfConstants.DB_DRVR);
    } catch(Exception e) {
        System.out.println("openDb(PrfDb): Class.forName() failed. e= "
+ e.getMessage());
        return (false);
      }

    // Connect to database
    System.out.println("openDb(PrfDb):Connecting to Database. URL =
jdbc:postgresql:prfdb...");
    try {
      connect = DriverManager.getConnection("jdbc:postgresql:prfdb",
"postgres", "");
    } catch (SQLException e) {
        System.out.println("openDb(PrfDb): Could not connect to
database. e=" + e.getMessage() );
        connect = null;
        return (false);
      } catch (Exception e) {
          System.out.println("openDb(PrfDb): Could not connect. e= " +
e.getMessage());
          connect = null;
          return (false);
        }

Can someone please help me. This has been much more complicated than
what I'd anticipated.

I'm not sure if this is a problem at Java end or the PostgreSQL end. So,
please
excuse me if I've posted this problem to the wrong group. I'm just
desperate for help !!!

Thanks much in advance.
Nishi

--------To err is human but to really mess it up is computer--------
mailto:nishikant.x.kapoor@nspco.com   http://www.c3ipros.com/nkapoor
-----------------------------------~~~------------------------------


Re: No DB connection in Netscape ? Please help.

От
Kenny Freeman
Дата:
I could be on thin ice, but applets can only make connections to the site
that they were loaded from. I noticed a security... something or other in
the java console o/p (just a quick look). Maybe that explains why you can
connect on one machine, and not the other....

On Fri, 14 Aug 1998, Kapoor, Nishikant X wrote:

> Hello friends
>
> I have apache-1.1.3-3 and PostgreSQL-6.3.2 running on my Linux RH4.2,
> kernel 2.0.30 (genx). I have a Java Applet that tries to connect to
> PostgreSQL
> using JDBC, from NS-4.5b1 on an IBM RISC6000, AIX-4.1.4 (mm01).
>
> Typing "mm01: netscape http://genx/PrfApplet.htm" brings up the applet
> in the NS
> but the database connection is not established. The Java console shows:
>
> openDb(PrfDb):Connecting to Database URL = jdbc:postgresql:prfdb...
> openDb(PrfDb): Could not connect. e= security.Couldn't connect to
> 'localhost' with origin from 'genx'.
>
> The same problems exits when I start NS from the same machine where the
> PostgreSQL
> server is running i.e. the Linux box(genx).
>
> *** But, when I use "genx: netscape http://127.0.0.1/PrfApplet.htm" on
> genx, the
> *** database connection gets established.
>
> The two machines genx and mm01 are on the same network and can ping each
> other
> using the hostnames.
>
> THE CLASSPATH IS *NOT* SET ON RISC MACHINE (mm01) and the postgresql.jar
> is already
> in mm01:$MOZILLA_HOME/java/classes. The JDBC interface is as follows:
>
>     // Load the driver
>     try {
>       Class.forName(PrfConstants.DB_DRVR);
>     } catch(Exception e) {
>         System.out.println("openDb(PrfDb): Class.forName() failed. e= "
> + e.getMessage());
>         return (false);
>       }
>
>     // Connect to database
>     System.out.println("openDb(PrfDb):Connecting to Database. URL =
> jdbc:postgresql:prfdb...");
>     try {
>       connect = DriverManager.getConnection("jdbc:postgresql:prfdb",
> "postgres", "");
>     } catch (SQLException e) {
>         System.out.println("openDb(PrfDb): Could not connect to
> database. e=" + e.getMessage() );
>         connect = null;
>         return (false);
>       } catch (Exception e) {
>           System.out.println("openDb(PrfDb): Could not connect. e= " +
> e.getMessage());
>           connect = null;
>           return (false);
>         }
>
> Can someone please help me. This has been much more complicated than
> what I'd anticipated.
>
> I'm not sure if this is a problem at Java end or the PostgreSQL end. So,
> please
> excuse me if I've posted this problem to the wrong group. I'm just
> desperate for help !!!
>
> Thanks much in advance.
> Nishi
>
> --------To err is human but to really mess it up is computer--------
> mailto:nishikant.x.kapoor@nspco.com   http://www.c3ipros.com/nkapoor
> -----------------------------------~~~------------------------------
>


Re: [GENERAL] No DB connection in Netscape ? Please help.

От
Amos Hayes
Дата:
On Fri, 14 Aug 1998, Kapoor, Nishikant X wrote:

> Typing "mm01: netscape http://genx/PrfApplet.htm" brings up the applet
> in the NS
> but the database connection is not established. The Java console shows:
>
> openDb(PrfDb):Connecting to Database URL = jdbc:postgresql:prfdb...
> openDb(PrfDb): Could not connect. e= security.Couldn't connect to
> 'localhost' with origin from 'genx'.


> The same problems exits when I start NS from the same machine where the
> PostgreSQL
> server is running i.e. the Linux box(genx).
>
> *** But, when I use "genx: netscape http://127.0.0.1/PrfApplet.htm" on
> genx, the
> *** database connection gets established.


I'm guessing that you have to configure postgress to allow connections
from other hosts. In the fist case, you are comming from another machine
and it won't let you in. In the second case, you are comming from the same
machine but using the machine's hostname. In this case, your IP stack is
telling itself that the connection is comming from your IP address not
your localhost address, so it won't let that in either. The third try
works because postgres is told that the connection is comming from
127.0.0.1 which it is (by default I assume) configured to accept.

This is behaviour that I've seen for all sorts of other access control
situations, so I'm guessing it's the problem here. If I'm not mistaken,
you want to have a look at the pg_access man page and the pg_hba.conf
file.


--
Amos Hayes                      Systems Architect
ahayes@ingenia.com            Ingenia Group - Software Kinetics Ltd.
http://smurf.ingenia.com/~ahayes        http://www.ingenia.com

"Remember: No one can make you feel inferior without your consent."
   - ELEANOR ROOSEVELT



Re: [INTERFACES] No DB connection in Netscape ? Please help.

От
Peter T Mount
Дата:
On Fri, 14 Aug 1998, Kapoor, Nishikant X wrote:

> Hello friends
>
> I have apache-1.1.3-3 and PostgreSQL-6.3.2 running on my Linux RH4.2,
> kernel 2.0.30 (genx). I have a Java Applet that tries to connect to
> PostgreSQL
> using JDBC, from NS-4.5b1 on an IBM RISC6000, AIX-4.1.4 (mm01).
>
> Typing "mm01: netscape http://genx/PrfApplet.htm" brings up the applet
> in the NS
> but the database connection is not established. The Java console shows:
>
> openDb(PrfDb):Connecting to Database URL = jdbc:postgresql:prfdb...
> openDb(PrfDb): Could not connect. e= security.Couldn't connect to
> 'localhost' with origin from 'genx'.
>
> The same problems exits when I start NS from the same machine where the
> PostgreSQL
> server is running i.e. the Linux box(genx).
>
> *** But, when I use "genx: netscape http://127.0.0.1/PrfApplet.htm" on
> genx, the
> *** database connection gets established.

Have you configured pg_hba.conf to allow connections from mm01 to the
database?

By default, it allows connections from localhost (127.0.0.1) but for other
remote hosts, you have to add their (or a subnet's) IP address/mask before
PostgreSQL will allow a connection.

> The two machines genx and mm01 are on the same network and can ping each
> other
> using the hostnames.

This is the same reason why genx fails - the host name is using the
ethernet port,  and not localhost.

>
> THE CLASSPATH IS *NOT* SET ON RISC MACHINE (mm01) and the postgresql.jar
> is already
> in mm01:$MOZILLA_HOME/java/classes.

The fact that you are getting connections failing or succeeding rules this
out. If it was a classpath problem, you'd be getting different exceptions
being thrown.

AFAIK, browsers don't use CLASSPATH anyhow.

> Can someone please help me. This has been much more complicated than
> what I'd anticipated.
>
> I'm not sure if this is a problem at Java end or the PostgreSQL end. So,
> please
> excuse me if I've posted this problem to the wrong group. I'm just
> desperate for help !!!

It looks like postgres is not allowing the connection, so the first place
to check is pg_hba.conf

--
Peter T Mount peter@retep.org.uk or petermount@earthling.net
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres