我相信这是SQL2000/2005中的一个bug/问题...如果我的结果在DATETIME列上为null,我会得到
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,它是一个日期时间。我真的不能添加任何东西,因为我不允许改变现有的表结构,这是一个很大的系统。也许我可以在我的SQL中进行类型转换?我不太确定这是否肯定是一个空问题..在我调用getDate()之前,是否可以调试/监视ResultSet并检查是否检索到任何数据? /EIDT
发布于 2011-05-24 17:50:06
如果您的应用程序(或驱动程序)无法处理空日期,那么最简单的方法可能是使用ISNULL(field,)并检查代码中的空替换日期。这种方法使用一个幻数(日期)来表示空值,即true。它不是很漂亮,但它是快速和直接的。
发布于 2011-05-24 17:44:29
你不能为此使用coalesce吗?
http://msdn.microsoft.com/en-us/library/ms190349.aspx
发布于 2011-05-24 17:54:49
您是从字段中选择datetime还是在SELECT中动态构建它?您可能需要对结果执行CAST操作。
请参阅this article
https://stackoverflow.com/questions/6108510
复制相似问题