Обсуждение: CallableStatements: index starts at 2

Поиск
Список
Период
Сортировка

CallableStatements: index starts at 2

От
Thomas Frieling
Дата:
It seems that in Version "8.2dev-500 JDBC 3" CallableStatements are
implemented differently from older Versions.
The index to set fields now starts at 2.

This _did_ work:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 1, "abc" );

This _now_ works:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 2, "abc" );

Thanks,
Thomas


Re: CallableStatements: index starts at 2

От
Andres Olarte
Дата:
You probably should use prepareStatement instead of prepareCall.  I had the same problem.  You can search the archives to look for a better explanation which I don't remmember right now

On 12/14/05, Thomas Frieling <frieling@8hertz.de> wrote:
It seems that in Version "8.2dev-500 JDBC 3" CallableStatements are
implemented differently from older Versions.
The index to set fields now starts at 2.

This _did_ work:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 1, "abc" );

This _now_ works:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 2, "abc" );

Thanks,
Thomas


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly

Re: CallableStatements: index starts at 2

От
Dave Cramer
Дата:
I just checked in a fix for this. It hasn't been well tested on all the various servers so please report problems back to me.

dave
On 14-Dec-05, at 11:38 AM, Andres Olarte wrote:

You probably should use prepareStatement instead of prepareCall.  I had the same problem.  You can search the archives to look for a better explanation which I don't remmember right now

On 12/14/05, Thomas Frieling <frieling@8hertz.de> wrote:
It seems that in Version "8.2dev-500 JDBC 3" CallableStatements are
implemented differently from older Versions.
The index to set fields now starts at 2.

This _did_ work:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 1, "abc" );

This _now_ works:
CallableStatement cS = con.prepareCall("{ call test(?)}";
cS.setString( 2, "abc" );

Thanks,
Thomas


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly


Re: CallableStatements: index starts at 2

От
Kris Jurka
Дата:

On Wed, 14 Dec 2005, Dave Cramer wrote:

> I just checked in a fix for this. It hasn't been well tested on all the
> various servers so please report problems back to me.

This fix only works on JDK1.4 builds.  It doesn't work on 1.2, 1.3, or 1.5
because you've only modified Jdbc3CallableStatement.  This also indicates
the fragility of the adjustIndex parameter.  Unfortunately we can't create
an AbstractJdbc2CallableStatement because we'd need multiple inheritance
for Jdbc3CallableStatement to extend both AbstractJdbc3Statement and
AbstractJdbc[2|3]CallableStatement.

Also your test case using the function getVoid does not work against 7.2
servers because the void pseudotype was added in 7.3.  The void type
doesn't seem to be important for testing.  You should be able to call a
function returing anything and ignore the result.

Kris Jurka

Re: CallableStatements: index starts at 2

От
Kris Jurka
Дата:

On Wed, 14 Dec 2005, Dave Cramer wrote:

> I just checked in a fix for this. It hasn't been well tested on all the
> various servers so please report problems back to me.
>

Doesn't this also need to be backpatched to 8.1.

Kris Jurka

Re: CallableStatements: index starts at 2

От
Dave Cramer
Дата:
Well, I was waiting for exactly this report before backpatching
anything.

Dave
On 15-Dec-05, at 5:13 PM, Kris Jurka wrote:

>
>
> On Wed, 14 Dec 2005, Dave Cramer wrote:
>
>> I just checked in a fix for this. It hasn't been well tested on
>> all the various servers so please report problems back to me.
>
> This fix only works on JDK1.4 builds.  It doesn't work on 1.2, 1.3,
> or 1.5 because you've only modified Jdbc3CallableStatement.  This
> also indicates the fragility of the adjustIndex parameter.
> Unfortunately we can't create an AbstractJdbc2CallableStatement
> because we'd need multiple inheritance for Jdbc3CallableStatement
> to extend both AbstractJdbc3Statement and AbstractJdbc[2|3]
> CallableStatement.
>
> Also your test case using the function getVoid does not work
> against 7.2 servers because the void pseudotype was added in 7.3.
> The void type doesn't seem to be important for testing.  You should
> be able to call a function returing anything and ignore the result.
>
> Kris Jurka
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>


Re: CallableStatements: index starts at 2

От
Kris Jurka
Дата:

On Thu, 15 Dec 2005, Kris Jurka wrote:

> On Wed, 14 Dec 2005, Dave Cramer wrote:
>
>> I just checked in a fix for this. It hasn't been well tested on all the
>> various servers so please report problems back to me.
>
> This fix only works on JDK1.4 builds.  It doesn't work on 1.2, 1.3, or 1.5
> because you've only modified Jdbc3CallableStatement.  This also indicates the
> fragility of the adjustIndex parameter.  Unfortunately we can't create an
> AbstractJdbc2CallableStatement because we'd need multiple inheritance for
> Jdbc3CallableStatement to extend both AbstractJdbc3Statement and
> AbstractJdbc[2|3]CallableStatement.

Fixed and backpatched to 8.1.

Kris Jurka