Re: PreparedStatement suggestion

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Philip Crotwell <crotwell(at)seis(dot)sc(dot)edu>
Cc: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: PreparedStatement suggestion
Date: 2001-02-01 09:13:27
Message-ID: 981018807.3a7928b76c21d@webmail.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Quoting Philip Crotwell <crotwell(at)seis(dot)sc(dot)edu>:

>
> 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

Good idea. I'll implement this tonight (possibly earlier). Would it be useful
to put the index value in the string as well?

As for the url's, yes they are broken. This is in part on how the pages are
designed. I've just haven't had chance to fix it yet (aiming for the weekend
for this one).

Peter

--
Peter Mount peter(at)retep(dot)org(dot)uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message v j 2001-02-01 13:16:10 JDBC APPLET Problem
Previous Message William Webber 2001-02-01 03:56:31 DatabaseMetaData.getIndexInfo() added