我相信這已經在SQL 2000/2005的錯誤/問題...如果我的成績有空的DATETIME列,我得到轉換是空日期不支持
com.microsoft.sqlserver.jdbc.sqlserverexception:
the conversion from int to date is unsupported
當我使用sql.getDate("ColumnName")
... 任何解決方案?下面
[編輯] 大家好感謝您的投入,是我的SQL查詢
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;
,這裏的罪魁禍首是tranchestartdate這是一個DATETIME。我無法真正添加任何tabel,因爲我不允許更改現有的表結構,這是一個很大的系統。也許我可以在我的SQL中進行投射?我不太確定這是否肯定是空的問題..可以通過ResultSet調試/監視並檢查是否有任何數據在我調用getDate()之前檢索? [/ EIDT]
沒有'null'日期? – Oded 2011-05-24 09:43:34
JDBC認爲該列是int必須有一個原因。你確定SQL字段不是TIMESTAMP數據類型嗎? – 2011-05-24 09:46:07
@詹姆斯。沒有任何轉換的'NULL'文字被SQL Server視爲'int',但'int'確實轉換爲'datetime'。 'SELECT CAST(0 AS DATETIME)'賦予'1900-01-01 00:00:00.000'和'SELECT CAST(CAST(NULL AS INT)AS DATETIME)''NULL' – 2011-05-24 09:50:17