Skip site navigation (1) Skip section navigation (2)

PreparedStatement suggestion

From: Philip Crotwell <crotwell(at)seis(dot)sc(dot)edu>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: PreparedStatement suggestion
Date: 2001-01-31 16:35:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

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 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.
Parameter index out of range, too large.
or something.

Just a thought,

PS some of the links on seem to be broken in the left
side navigation. For example Download points to
but it should be

In response to


pgsql-jdbc by date

Next:From: William WebberDate: 2001-02-01 03:56:31
Subject: DatabaseMetaData.getIndexInfo() added
Previous:From: Peter T MountDate: 2001-01-31 08:30:27
Subject: Re: JDBC Connection Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group