Archive for September, 2005

Sybase JDBC and execute()

Wednesday, September 7th, 2005

OK, found an interesting bug in the Sybase jConnect JDBC drivers for 5.5 and 6.0. Seems that the execute() command does not respect the transactional nature of the system. For example, if the SQL to execute includes a begin transaction and end transaction with some interesting SQL in the middle, then the execute() will not really commit the changes to the database when the command returns. In order to do that you need to use the executeQuery() - even if you don't care about the return values.

This nailed me for about three days because I was worried that data wasn't getting written to the database as it should. I implemented a read-after-write scheme and even that told me that things were indeed getting written only to see that they really weren't in the database. Why? Because for the transaction, the data was there and that meant that the reads were within the transaction and therefore "saw" the data. Yet, then the JDBC connection was dropped the data was all rolled back.

One more reason to hate JDBC.