PreparedStatement suggestion

Поиск
Список
Период
Сортировка
От Philip Crotwell
Тема PreparedStatement suggestion
Дата
Msg-id Pine.GSO.4.10.10101311120490.8112-100000@tigger.seis.sc.edu
обсуждение исходный текст
Ответ на Re: to much process  (Richard Bullington-McGuire <rbulling@microstate.com>)
Ответы Re: PreparedStatement suggestion
Список pgsql-jdbc
Hi

Not sure if it is easy or not given the translation in PSQLException, but
it would be nice if the paramIndex could be included in the error message
when it is out of range. An alternative would be to have one message for
paramIndex == 0 and another for paramIndex > inStrings.length.

This would help users find stupid bugs like using index=0, which is
likely to be a common bug IMHO. ( Yes, you guessed it, I just found an
index=0 bug in my code :)

Perhaps something like changing set from PreparedStatement.java to:

    private void set(int paramIndex, String s) throws SQLException
    {
        if (paramIndex < 1)
            throw new PSQLException("postgresql.prep.rangesmall");
        if (paramIndex > inStrings.length)
            throw new PSQLException("postgresql.prep.rangelarge");
        inStrings[paramIndex - 1] = s;
    }

And then have the messages be:
Parameter index out of range, less than one.
and
Parameter index out of range, too large.
or something.

Just a thought,
thanks,
Philip

PS some of the links on jdbc.postgres.org seem to be broken in the left
side navigation. For example Download points to
http://jdbc.postgresql.org/postgres/download.html
but it should be
http://jdbc.postgresql.org/download.html



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

Предыдущее
От: Peter T Mount
Дата:
Сообщение: Re: [INTERFACES] JDBC Connection Problem
Следующее
От: Peter T Mount
Дата:
Сообщение: Re: PreparedStatement suggestion