Re: Suggestion for an improvement... ("database" part missing in URI)

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Thomas Haeberlen'" <Haeberlen(at)RUS(dot)Uni-Stuttgart(dot)DE>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Suggestion for an improvement... ("database" part missing in URI)
Date: 2002-03-19 20:23:50
Message-ID: 013401c1cf83$fb09bf70$807ba8c0@inspiron
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Yes, you are correct, it shouldn't NPE when you don't put the database
in

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Thomas Haeberlen
> Sent: Tuesday, March 19, 2002 1:43 PM
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: [JDBC] Suggestion for an improvement... ("database"
> part missing in URI)
>
>
> Hello list, especially hello developers,
>
> I am new to PostgreSQL and I tried the Postgresql jdbc driver for the
> first time today, so please bear with me if the following
> sounds silly:
>
> I have a suggestion for a small but probably helpful
> improvement for the next release:
>
> When I omit the "database" part in the database URI used in
>
> DriverManager.getConnection("jdbc:postgresql://hostname/databa
> se", ... )
>
> the error message is not very helpful:
>
> ----------------------------- snip
> -------------------------------------
> Something unusual has occured to cause the driver to fail.
> Please report this exception: Exception:
> java.lang.NullPointerException Stack Trace:
>
> java.lang.NullPointerException
> at
> org.postgresql.Connection.openConnection(Connection.java:155)
> at org.postgresql.Driver.connect(Driver.java:149)
> at
> java.sql.DriverManager.getConnection(DriverManager.java:517)
> at
> java.sql.DriverManager.getConnection(DriverManager.java:177)
> at testpgsql.main(testpgsql.java:13)
> End of Stack Trace
>
> --------------------------------------------------------------
> ----------
>
> and on the postmaster's stderr you get
>
> DEBUG: pq_recvbuf: unexpected EOF on client connection
> DEBUG: incomplete startup packet
>
> This had me searching for some obscure error in my setup
> (networking, db access permissions, and all that) for several
> hours until I finally
> discovered that all that was missing was indeed the database name...
>
> Couldn't this error be caught right at the beginning when the
> URI is read?
>
> I guess this might be a quite common error and I'd say it
> would be a lot more "user-friendly" (well, ok, programmer
> friendly) if there could be an
> exception with a more meaningful message like for example
> "database name
> missing in URI" or at least "invalid URI" instead of a
> SQLException triggered
> by a NullPointerException...
>
> Anyhow, I hope this message might at least be useful for
> others and save them some time when they make the same mistake :-)
>
> Cheers
>
> Thomas
>
>
> --
> Thomas Haeberlen
> Rechenzentrum Universitaet Stuttgart (RUS)
> Abteilung Informationsdienste
> Allmandring 30 , D-70569 Stuttgart
> Email: haeberlen(at)rus(dot)uni-stuttgart(dot)de
> Phone: +49 711 685 47 19 Fax: +49 711 678 76 26
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-03-19 22:23:06 7.2 Driver known issues and looking for testers
Previous Message Thomas Haeberlen 2002-03-19 18:42:47 Suggestion for an improvement... ("database" part missing in URI)