Bug report: NullPointerException from Driver.connect when passed a Properties with non-string values

Поиск
Список
Период
Сортировка
От Nathaniel Waisbrot
Тема Bug report: NullPointerException from Driver.connect when passed a Properties with non-string values
Дата
Msg-id 74B305A4-D481-4D4C-8E0E-8EBAB50CF584@highfleet.com
обсуждение исходный текст
Ответы Re: Bug report: NullPointerException from Driver.connect when passed a Properties with non-string values
Re: Bug report: NullPointerException from Driver.connect when passed a Properties with non-string values
Список pgsql-jdbc
I found this while working with another JDBC driver (Stels XML driver).  The Postgresql driver's connect() method is
expectingthe passed Properties object to have only string values, but this is not actually guaranteed to be the case.
Ithink that the PG driver should wrap the NullPointerException in a SQLException, which would allow the DriverManager
toattempt to use other JDBC drivers to make the connection. 

Here is a simple Java program which will reproduce the problem:

==================
import java.sql.DriverManager;
import java.util.Properties;

public class PGTest {
    public static void main(String[] args) throws Exception {
        Class.forName("org.postgresql.Driver");
        Properties info = new Properties();
        info.put("foo", new Object());      // info.getPropert("foo") will return null
        DriverManager.getConnection("foo:bar//baz", info);
    }
}
==================

and here is the stack trace produced by running that program:

==================
Exception in thread "main" java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:542)
    at java.util.Properties.setProperty(Properties.java:161)
    at org.postgresql.Driver.connect(Driver.java:244)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:190)
    at PGTest.main(PGTest.java:9)
==================

I'm using postgresql-9.2-1002.jdbc4.jar, with Java 7, running on Mac OS 10.8.2.  Output of java -version:
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)



В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: JDBC connection test with SSL on PG 9.2.1 server
Следующее
От: dmp
Дата:
Сообщение: Re: [BUGS]log can not be output when use DataSource