Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Ibatis with Spring

843859Mar 19 2009 — edited Mar 24 2009
Hi everybody,
I'm using Ibatis with Spring for Java Database Connectivity and persistence and I have the following stackTrace when I try to insert some data in a table:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [HY004]; error code [0];
--- The error occurred in com/domain/dao/sqlmap/Errori.xml.
--- The error occurred while applying a parameter map.
--- Check the Errori.insertErrori-InlineParameterMap.
--- Check the parameter mapping for the 'fg_consmod' property.
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/domain/dao/sqlmap/Errori.xml.
--- The error occurred while applying a parameter map.
--- Check the Errori.insertErrori-InlineParameterMap.
--- Check the parameter mapping for the 'fg_consmod' property.
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]The specified SQL type is not supported by this driver.
at java.lang.Throwable.<init>(Throwable.java)
at java.lang.Throwable.<init>(Throwable.java)
at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:58)
at org.springframework.dao.DataAccessException.<init>(DataAccessException.java:55)
at org.springframework.jdbc.UncategorizedSQLException.<init>(UncategorizedSQLException.java:43)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
at org.springframework.orm.ibatis.SqlMapClientTemplate.insert(SqlMapClientTemplate.java:397)
at com.persistence.sqlmapdao.ErroriSqlMapDao.insertErrori(ErroriSqlMapDao.java:34)
at com.service.impl.SisErroriServiceImpl.insertErrori(SisErroriServiceImpl.java:36)
at com.sysdat.servlet.SysdatHttpServlet.doPost(SysdatHttpServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)

This is the xml file with thw queries
<sqlMap namespace="Errori">
	<typeAlias alias="errori" type="com.domain.Errori"/>
<insert id="insertErrori" parameterClass="errori">
  	insert into Errori (cod_err, des_err, tp_err, fg_consmod, fg_reg, lang, help, orig_err, dt_ins, id_help, modulo, livelo, cod_ute, flag_ins) 
  	values (#cod_err#, #des_err#, #tp_err#, #fg_consmod#, #fg_reg#, #lang#, #help#, #orig_err#, #dt_ins#, #id_help#, #modulo#, #livelo#, #cod_ute#, #flag_ins#)
  </insert>  
</sqlMap>
The following code is part of the Javabean with the field for wich I get problems:
private String fg_consmod;
My version of Ibatis is 2.3.0
Can you help me?
Thanks and regards

Comments

843859
I modified the xml like this:
	<parameterMap id="parameterErroriMap" class="errori">
		<parameter property="cod_err"         jdbcType="INT" 		javaType="Integer"/>
                <parameter property="lang"            jdbcType="VARCHAR" 	javaType="String"/>		
                <!-- misses text - dt_ins is datetime in the db table-->
		<parameter property="dt_ins"          jdbcType="VARCHAR" 	javaType="String"/>
		<!-- misses text-->
	</parameterMap>

  <update id="updateErrori" parameterMap="parameterErroriMap">
  	update Errori SET dt_ins = ?
  	where cod_err = ? AND lang = ?
  </update>
But now I get the following error:

org.springframework.dao.DataIntegrityViolationException: SqlMapClient operation; SQL [];
nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/domain/dao/sqlmap/Errori.xml.
--- The error occurred while applying a parameter map.
--- Check the Errori.parameterErroriMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]String data truncated
at java.lang.Throwable.<init>(Throwable.java:59)
at java.lang.Throwable.<init>(Throwable.java:89)
at org.springframework.core.NestedRuntimeException.<init>(NestedRuntimeException.java:58)
at org.springframework.dao.DataAccessException.<init>(DataAccessException.java:55)
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:100)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:212)
at org.springframework.orm.ibatis.SqlMapClientTemplate.update(SqlMapClientTemplate.java:411)
at com.persistence.sqlmapdao.ErroriSqlMapDao.updateErrori(ErroriSqlMapDao.java)
at com.service.impl.SisErroriServiceImpl.updateErrori(SisErroriServiceImpl.java:41)
at com.sysdat.servlet.SysdatHttpServlet.doPost(SysdatHttpServlet.java:77)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:116)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
843859
I found out the solution!

In the file xml I modified the code like this:
<typeAlias alias="errori" type="com.domain.Errori"/>

 <update id="updateErrori" parameterClass="errori" >
  	update Errori SET des_err = #des_err:VARCHAR#, tp_err = #tp_err:VARCHAR#, fg_consmod = #fg_consmod:VARCHAR#, fg_reg = #fg_reg:VARCHAR#, help = #help:VARCHAR#, orig_err = #orig_err:VARCHAR#, dt_ins = #dt_ins:TIMESTAMP#, id_help = #id_help:NUMERIC#, modulo = #modulo:VARCHAR#, livelo = #livelo:NUMERIC#, cod_ute = #cod_ute:VARCHAR#, flag_ins = #flag_ins:VARCHAR#
  	where cod_err = #cod_err# AND lang = #lang#
  </update>
Thanks and regards
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 21 2009
Added on Mar 19 2009
2 comments
3,075 views