日期:2014-05-20  浏览次数:20712 次

JAVA程序中把字符串插入SQL SERVER中的Date类型字段出错请教解决方案
各位大虾好!
我的代码如下:
    String   sql2   = "insert   into   Record   (Id,CardId,ComputerId,BeginTime)valus(?,?,?,?) ";
                                stm   =   con.prepareStatement(sql);
                                stm.setInt(1,   getNewId());
                                stm.setString(2,   CardId);
                                stm.setString(3,   ComputerId);
                                stm.setString(4,   displayNowTime);
                                stm.executeUpdate();
其中BeginTime是SimpleDate类型。displayNowTime值是String类型,值为2007-4-1   12:00:00,程序运行时的错误提示是java.sql.SQLException:   Driver   does   not   support   this   function或者是字符串插入Date字段时发生错误。

请问错误应该如何修改才可以?


------解决方案--------------------
SimpleDate类型应该只有日期,没有时间,displayNowTime换成2007-4-1试试
------解决方案--------------------
2007-4-1 12:00:00
这样也行的,只不过值插入前面的日期,楼主应该是其他地方的问题