dagblog.
← Archive

jTDS 0.8.1 was a long time coming


We’ve worked with MSSQL databases in our applications for a long time. We first used Sun’s standard driver, then went looking for a better one from Microsoft. The Microsoft driver only worked from SQL2000 onward. Eventually we found JTDS.

We were delighted. It could do almost everything we needed at the time. Problems with SQL2000 instances did come up later, and for those we have to use the Microsoft driver. (Dagi’s note: 0.7.1 and earlier didn’t support instances at all.) Otherwise it worked. Except for rowsAffected!

What do you think about controlling program flow by checking rowsAffected? It has both supporters and opponents at our company. I used to be in the camp that said if I call statement.executeUpdate, I can base the program’s logic on how many rowsAffected it returns. Usually all we care about is whether it’s 0, 1 or n.

Unfortunately, jTDS didn’t return that number correctly at the time. It finally started working in version 0.7.1. Another problem we ran into with jTDS was batchUpdate. Sometimes you can’t use it. For example, I had 50 nearly identical inserts, updates or deletes on a single table. That would be ideal for batchUpdate if the table weren’t so busy, but mine was.

My series of batch updates neatly locked the whole table, and that was that. Running each insert, update or delete separately made everything work again. In situations where batching was ideal, we incorporated batchUpdate. Imagine our surprise when testing produced messages like “Method not supported yet.” The new jTDS puts that behind us, too. I’m leaving aside teething troubles such as not being able to insert into more than about 40 columns with INSERT-VALUES. The jTDS folks fixed those in version 0.7.1.

What makes 0.8.1 interesting, then? The developers tested it with Hibernate and fixed quirks they wouldn’t have seen otherwise. A belated apology to my colleague TZ, who spent two days trying to work out why rowsAffected wasn’t working in Hibernate when it should have been working since 0.7.1. Next time I’ll update the drivers more often :-). That leaves one last wish. May jTDS finally support SQL2000 instances.

Medium version

Related articles

Related CZ Podcast episodes