[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: JDBC API weirdness?
Bernard,
This problem is fixed in 0.93. It was a bug with how parameters were
passed in the TCP client/server protocol.
Toby.
Bernard wrote:
>
> Hi all,
>
> I just found a very strange behavior with PreparedStatement and would
> like to hear comments about it from the people in the list.
>
> I hope the pseudo code fragement explains it:
>
> PreparedStatement pStmt = con.prepareStatement(
> "INSERT INTO TMP VALUES(?,?,?)");
> pStmt.setString(2,"value 2");
> pStmt.setString(3,"value 3");
> pStmt.setString(1,"value 1");
>
> pStmt.executeUpdate();
>
> I ran this before without problems I think under Sun's JDK1.3 and
> Mckoi 0.9.2.
>
> It crashes under Sun's JDK1.4 and Mckoi 0.9.2 apparently only if the
> parameters are set out of (ascending parameter index) order.
>
> From looking at the Mckoi debug log it appears that
>
> pStmt.setString(1,"value 1");
>
> clears the params array except the one with index 1.
> Then Mckoi DB crashes with an ArrayIndexOutOfBounds Exception.
>
> So I re-ordered the statements and the problem is gone.
>
> I read the JDBC API again very carefully but I could not find a
> constraint such as the setter methods have to be in parameter index
> order.
>
> Is this a bug in JDK 1.4 or Mckoi or just a combination?
>
> I haven't been able to try this in Mckoi DB 0.9.3 preview yet.
>
> Many thanks,
> Bernard