Re: Suggestion for an improvement... ("database" part missing in URI)
От | Dave Cramer |
---|---|
Тема | Re: Suggestion for an improvement... ("database" part missing in URI) |
Дата | |
Msg-id | 013401c1cf83$fb09bf70$807ba8c0@inspiron обсуждение исходный текст |
Ответ на | Suggestion for an improvement... ("database" part missing in URI) (Thomas Haeberlen <Haeberlen@RUS.Uni-Stuttgart.DE>) |
Список | 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@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Thomas Haeberlen > Sent: Tuesday, March 19, 2002 1:43 PM > To: pgsql-jdbc@postgresql.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@rus.uni-stuttgart.de > Phone: +49 711 685 47 19 Fax: +49 711 678 76 26 > > ---------------------------(end of > broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > >
В списке pgsql-jdbc по дате отправления: