I believe this has been a bug/problem in SQL 2000/2005 … If my results have null on DATETIME column, i get
com.microsoft.sqlserver.jdbc.sqlserverexception:
the conversion from int to date is unsupported
when i use sql.getDate("ColumnName") …
Any solutions to this?
[EDIT]
Hi all thanks for your inputs, below is my SQL query
select p.planno as PlanNumber,
t.TrancheID as TrancheID,
t.tranchestartdate as TrancheStartDate,
t.tranchereasoncode as TrancheReasonCode,
ai.ArrayItemDecode TrancheReasonDescription,
t.trancheuwstage as UnderwritingStatusCode
from plan_ p
inner join tranche t
on t.planno = p.planno
and t.trancheuwstage in ( 2, 4 )
and p.planno = '040000000X6'
inner join arrayitem ai
on ai.ArrayNm = 'arrTraReas'
and ai.ArrayItemCode = t.tranchereasoncode;
and the culprit here is tranchestartdate which is a DATETIME. I can’t really add anything to tabel as i’m not allowed to change existing table structures, this is a big system. Perhaps i can do the casting in my SQL? I’m not quite sure if this is definitely a null problem.. Can one debug/watch through the ResultSet and check if any data was retrieved before i call getDate()?
[/EIDT]
If your application (or drivers) cannot handle null dates then the easiest thing might be to use ISNULL(field, <null replacement date>) and check for the null replacement date in code. This approach uses a magic number (date) to indicate null values, true. It’s not pretty but it is quick and straightforward.