spent lot of time geting @@INDENTITY returned using microsoft jdbc sql server
driver. it always return 0. changed the driver to jtds from sf.net it
worked like a charm.
here is my config.xml defining connection information
--------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2006 sp2 U (http://www.altova.com) by Amit Singh
(Merrill Lynch) -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="dataSourceMarketIntel"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<!--
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
-->
<value>net.sourceforge.jtds.jdbc.Driver</value>
</property>
<property name="url">
<!--
<value>jdbc:microsoft:sqlserver://host:port;DatabaseName=dbname</value>
-->
<value>jdbc:jtds:sqlserver://host:port/dbname</value>
</property>
<property name="username">
<value>dbuser</value>
</property>
<property name="password">
<value>dbpassword</value>
</property>
</bean>
</beans>
my sqlmapconfig file is as follows
--------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="100"
maxTransactions="100"
useStatementNamespaces="false"/>
<sqlMap resource="xcite/pst-config.xml"/>
</sqlMapConfig>
my pst-config.xml file is as follows
--------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="templates">
<insert id="insertStrips"
parameterClass="com.ekt.mktdata.vo.StripData">
insert into TSRSTRIPS ( Stripname, SeriesId,
InstrumentId, MonthStart,
MonthEnd, SpanYear, SpreadYear, SpreadYearCount)
values (#name#, #seriesId#, #instrumentId#,
#monthStart#,
#monthEnd#, #spanYear#, #spreadYear#, #spreadYearCount#)
<selectKey type="post" resultClass="java.lang.Integer">
SELECT @@IDENTITY AS ID
</selectKey>
</insert>
</sqlMap>
----------------------------------------------
code to invoke insert is as follows
----------------------------------------------
c
public int insertStrip(StripData strip) {
Integer result =
(Integer)getSqlMapClientTemplate().insert("insertStrips",
strip);
System.out.println("insertStrip: " + result);
return retult.intValue();
}
--
View this message in context:
http://www.nabble.com/%40%40IDENTITY-problem-with-mssql-drivers.-%28-sol.-use-jtds-drivers-form-sf.net%29-tf3499293.html#a9772816
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.