ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hegarty <matthew.hega...@diagonal-consulting.com>
Subject RE: Inserting null into SQLServer DATETIME field
Date Wed, 19 Oct 2005 09:20:11 GMT
Thanks - that seems to have sorted it.
For some reason I thought you specified the DB field type in the mapping,
not the java type.


  _____  

From: Niels Beekman [mailto:n.beekman@wis.nl] 
Sent: 19 October 2005 10:06
To: user-java@ibatis.apache.org
Subject: RE: Inserting null into SQLServer DATETIME field



Hi,

 

java.sql.Types.DATETIME does not exist in Java 1.4, we use TIMESTAMP, see
the API of your Java-version...

 

Niels

 


  _____  


From: Matthew Hegarty [mailto:matthew.hegarty@diagonal-consulting.com] 
Sent: woensdag 19 oktober 2005 11:01
To: user-java@ibatis.apache.org
Subject: Inserting null into SQLServer DATETIME field

 

All 

I am having trouble inserting null values into a SQL Server DATETIME field. 

I have specified the following mapping: 

<insert id="insertTaskInstance" parameterClass="taskInstance"> 
    insert into TASK_INSTANCES (START_DATETIME, END_DATETIME, ID_TASK_TYPE,
ID_TASK_STATE) 
    values (#startDateTime#, #endDateTime:DATETIME#, #idTaskType#,
#idTaskState#) 
        <selectKey resultClass="long"> 
                SELECT @@IDENTITY AS ID 
        </selectKey> 
</insert> 

If the endDateTime value is null (otherwise is fine) the call to insert
fails with the following error: 

junit.framework.AssertionFailedError: DAO Error: Failed to insert - id
[insertTaskInstance], parameterObject [....dto.TaskInstance@11563ff]. Cause:
com.ibatis.common.jdbc.exception.NestedSQLException:   

--- The error occurred in ..../dao/sql/TaskInstanceSQL.xml.  
--- The error occurred while applying a parameter map.  
--- Check the insertTaskInstance-InlineParameterMap.  
--- Check the parameter mapping for the 'endDateTime' property.  
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]The specified SQL type is not supported by this driver.

Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]The specified SQL type is not supported by this driver.

        at junit.framework.Assert.fail(Assert.java:47) 

However if I specify '#endDateTime:DATE#' (not DATETIME) an insert of null
is fine (though this is not acceptable for me because when a date is passed
the time portion of the date is lost).

The underlying field is DATETIME (length=8) 

I am using the latest SQLMaps DAO release. 

Any ideas? 

Matt 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Mime
View raw message