Re: [QUESTIONS] JDBC applet problems (fwd)

From: Peter T Mount <postgresdev(at)maidast(dot)demon(dot)co(dot)uk>
To: Felix Morley Finch <felix(at)crowfix(dot)com>
Cc: PostgreSQL Interfaces <pgsql-interfaces(at)postgresql(dot)org>, PostgreSQL Questions <pgsql-questions(at)postgresql(dot)org>
Subject: Re: [QUESTIONS] JDBC applet problems (fwd)
Date: 1998-04-17 11:45:14
Message-ID: Pine.LNX.3.95.980417124359.27499B-100000@maidast.demon.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

[This should be on the interfaces list. Replying to both as some replies
are already on questions]

On 16 Apr 1998, Felix Morley Finch wrote:

> I've gotten stuck learning several things at once, and need some
> advice. This is Postgres 6.3, Linux 2.0.33, Netscape 4.05 with jdk
> 1.1 (just released), jdk 1.1.5 v5 glibc.
>
> I have a lot of experience with C and Unix, only about 6 months with
> SQL, and only about 6 months with Java, and most of the Java was
> teaching myself by working on a standalone program for my own use. My
> applet experience before this latest self-teaching project has been
> HelloWorld, and when my Netscape CLASSPATH was wrong, I kept fussing
> with Apache, forgetting that applets are client side, not server side
> like CGIs, so I realize I am probably doing something really really
> newbie-wrong here :-)
>
> I am trying to write an applet which will connect to postgres, display
> and search a database, allow editing, etc. Just a very simple
> interface, mostly for learning something new, partly to get a
> replacement for an existing CGI Perl program which works fine but
> is slow (all this is running on a 486).
>
> I first wrote the Java code as a standalone program, following the
> jdbc/psql example. That works, it connects, feeds in sql, gets
> results. When I converted it to an applet, it no longer connects.
> (Yes, postmaster has the -i option :-)
>
> I get two kinds of errors: user authentication, and no suitable
> driver. It seems to switch between the two, almost randomly, or at
> least without any strong correlation I can find. I believe it is
> finding postgresql.jar, because if I take that out of Netscape's
> CLASSPATH, it gets different errors. I also had to add every Netscape
> jar file to Netscape's CLASSPATH or it couldn't find java.sql.

Ok. First the user authentication. This is failing because the
user/password information you are sending when connecting is not matching
the backend. If you have configured pg_hba.conf to use password or crypt,
then make sure that you have set the password in postges. IE:

db=> create user myuser;
db=> alter user myuser with password mypass;

Note: no quotes

Now the "no suitable driver". This is caused by the DriverManager not able
to find the driver. This is caused by two things:

For postgresql, the jdbc url must start with jdbc:postgresql: otherwise
the driver will ignore the url.

The other cause is that the driver is not installed. For applets, this
means including the postgresql.jar in the applet tag. Also, applets have
to use Class.forName("postgresql.Driver"); to load the driver (they can't
use the jdbc.drivers property).

--
Peter T Mount petermount(at)earthling(dot)net or pmount(at)maidast(dot)demon(dot)co(dot)uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter(at)maidstone(dot)gov(dot)uk

Browse pgsql-interfaces by date

  From Date Subject
Next Message Julia A.Case 1998-04-17 14:18:32 Re: [INTERFACES] ODBC 6.3.2
Previous Message Peter T Mount 1998-04-17 11:10:54 Solaris 2.6 binary for Postgresql (fwd)