Skip site navigation (1) Skip section navigation (2)

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

From: Thomas Haeberlen <Haeberlen(at)RUS(dot)Uni-Stuttgart(dot)DE>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Suggestion for an improvement... ("database" part missing in URI)
Date: 2002-03-19 18:42:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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/database", ... )

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:

        at org.postgresql.Connection.openConnection(
        at org.postgresql.Driver.connect(
        at java.sql.DriverManager.getConnection(
        at java.sql.DriverManager.getConnection(
        at testpgsql.main(
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 :-)



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


pgsql-jdbc by date

Next:From: Dave CramerDate: 2002-03-19 20:23:50
Subject: Re: Suggestion for an improvement... ("database" part missing in URI)
Previous:From: Oliver FriedrichDate: 2002-03-19 13:57:39
Subject: Resolving of reference/foreign keys

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group