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:
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@rus.uni-stuttgart.de
Phone: +49 711 685 47 19 Fax: +49 711 678 76 26