... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


MS SQL Server, invalid dates, and jTDS

We ran into a problem with the way SQL Server handles invalid dates.  If you attempt to execute a query with a date that is outside the SQL Server accept range, you get the message:

Only dates between January 1, 1753 and December 31, 9999 are accepted.

Furthermore, the server logs show messages like:

2004-08-12 15:56:47.77 spid51 Error: 17805, Severity: 20, State: 3
2004-08-12 15:56:47.77 spid51 Invalid buffer received from client.

Any finally, the server feels that the error is severe enough that it terminates the connection.  This is clearly a bug.  It is discussed in the Microsoft knowledge base article:


Notwithstanding the reference of the Microsoft JDBC driver in the article, this behaviour also occurs when using jTDS.  The only solution at this time is make sure that you don't send dates outside the mandated date range to the server.

This bug is particularly nasty when connection pooling is being used.  Pooled connections are rendered broken after this error occurs.  It is important to use some sort of dead connection testing

Blog Archive