Re: Strange crashes in JDBC code in multithreaded application.

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: Strange crashes in JDBC code in multithreaded application.
Дата
Msg-id Pine.BSO.4.64.0708042249250.9854@leary.csoft.net
обсуждение исходный текст
Ответ на Strange crashes in JDBC code in multithreaded application.  ("L. Rahyen" <research@science.su>)
Ответы Re: Strange crashes in JDBC code in multithreaded application.
Список pgsql-jdbc

On Sun, 5 Aug 2007, L. Rahyen wrote:

> Exception in thread "Thread-108" java.lang.NullPointerException
>   at
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:182)
>   at ...
>   at java.lang.Thread.run(libgcj.so.70)
>

This area of code reads:

175        if (parameters == null)
176            parameters = SimpleQuery.NO_PARAMETERS;
177
178        boolean describeOnly = (QUERY_DESCRIBE_ONLY & flags) != 0;
179
180        // Check parameters are all set..
181        if (!describeOnly)
182            ((V3ParameterList)parameters).checkAllParametersSet();

So it's complaining that parameters is null, but the code on line 175
should take care of that case.  I note that you're using GCJ, does this
problem occur when using a Sun JVM?

>     1) This is a bug in JDBC. Is JDBC thread-safe? Is it supposed to be
> thread-safe by design? Obviously if not then initializing conn
> every time will be inefficient and I need to write a separate server to
> execute PSQL queries because I want to connect only once to the DB.

JDBC is thread safe.  While PG's driver can only execute one query at a
time, it should block, not die like this.

Kris Jurka

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

Предыдущее
От: "L. Rahyen"
Дата:
Сообщение: Strange crashes in JDBC code in multithreaded application.
Следующее
От: "L. Rahyen"
Дата:
Сообщение: Re: Strange crashes in JDBC code in multithreaded application.