You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Randy Layman <Ra...@vocalocity.com> on 2006/11/16 16:19:52 UTC

Postgres Stored Procedures, wrong return type

 
	I'm trying to invoke a stored procedure in Postgres, but I get
an error from the Postgres driver saying (The entire stack trace for the
exception is at the end of the email):
org.postgresql.util.PSQLException: A CallableStatement function was
executed and the return was of type java.sql.Types=12 however type
java.sql.Types=0 was registered.
 

	I believe that I properly declared the JDBC Type on the
parameter map -- the relevant portion of my Sql Map:
<parameterMap id="mapRootDocument" class="map">
  <parameter property="param1" jdbcType="VARCHAR"
javaType="java.lang.String" mode="IN" />
  <parameter property="result" jdbcType="VARCHAR"
javaType="java.lang.String" mode="OUT" />
</parameterMap>
<procedure id="rootDocument" parameterMap="mapRootDocument">
  {call get_root_document(?, ?)}
</procedure>


	My procedure is declared as:
CREATE OR REPLACE FUNCTION get_root_document(deviceguid varchar, OUT
result varchar) AS $procedure$
BEGIN
  -- Do stuff here, assign a value to result
END;
$procedure$ LANGUAGE plpgsql;


	In my Java code I'm calling it with:
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("param1", p);
parameters.put("result", "");		// Also passed null here
sqlMap.queryForObject("rootDocument", parameters);


	I looked up the SQL Types that Postgres is complaining about --
Type 12 is VARCHAR and Type 0 is NULL.  It almost seems like the
jdbcType parameter is wrong -- I've used the wrong value or the
attribute name isn't quite right, but it looks right to me.

	I'm using Postgres 8.1 with iBATIS 2.1.7.

	Randy



2006-11-16 10:14:59,405 ERROR [STDERR]
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in iBatisProperties.xml.  
--- The error occurred while applying a parameter map.  
--- Check the DeviceProperties.mapRootDocument.  
--- Check the statement (update procedure failed).  
--- Cause: org.postgresql.util.PSQLException: A CallableStatement
function was executed and the return was of type java.sql.Types=12
however type java.sql.Types=0 was registered.
Caused by: org.postgresql.util.PSQLException: A CallableStatement
function was executed and the return was of type java.sql.Types=12
however type java.sql.Types=0 was registered.
2006-11-16 10:14:59,420 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:185)
2006-11-16 10:14:59,436 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForObject(GeneralStatement.java:104)
2006-11-16 10:14:59,436 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:561)
2006-11-16 10:14:59,436 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:536)
2006-11-16 10:14:59,436 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSes
sionImpl.java:93)
2006-11-16 10:14:59,452 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClie
ntImpl.java:70)
2006-11-16 10:14:59,452 ERROR [STDERR] 	at
com.vocalocity.hosted.appserver.config.IbatisConfigurationLoader.getRoot
Document(IbatisConfigurationLoader.java:60)
2006-11-16 10:14:59,452 ERROR [STDERR] 	at
com.vocalocity.hosted.appserver.config.ConfigurationManager.getRootDocum
ent(ConfigurationManager.java:38)
2006-11-16 10:14:59,452 ERROR [STDERR] 	at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Lja
va.lang.Object;)Ljava.lang.Object;(Unknown Source)
2006-11-16 10:14:59,467 ERROR [STDERR] 	at
jrockit.reflect.InitialMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lan
g.Object;)Ljava.lang.Object;(Unknown Source)
2006-11-16 10:14:59,467 ERROR [STDERR] 	at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)L
java.lang.Object;(Unknown Source)
2006-11-16 10:14:59,467 ERROR [STDERR] 	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
AopUtils.java:287)
2006-11-16 10:14:59,483 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinp
oint(ReflectiveMethodInvocation.java:181)
2006-11-16 10:14:59,483 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:148)
2006-11-16 10:14:59,483 ERROR [STDERR] 	at
org.springframework.transaction.interceptor.TransactionInterceptor.invok
e(TransactionInterceptor.java:96)
2006-11-16 10:14:59,483 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:170)
2006-11-16 10:14:59,498 ERROR [STDERR] 	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
pProxy.java:176)
2006-11-16 10:14:59,498 ERROR [STDERR] 	at
$Proxy251.getRootDocument(Ljava.lang.String;)Ljava.lang.String;(Unknown
Source)
2006-11-16 10:14:59,498 ERROR [STDERR] 	at
com.vocalocity.hdap.devices.DevicePropertiesRenderer.render(DeviceProper
tiesRenderer.java:92)
2006-11-16 10:14:59,498 ERROR [STDERR] 	at
com.vocalocity.hdap.appserver.render.RenderRouter.render(RenderRouter.ja
va:43)
2006-11-16 10:14:59,514 ERROR [STDERR] 	at
com.vocalocity.hdap.appserver.HDAPServlet.doRender(HDAPServlet.java:111)
2006-11-16 10:14:59,514 ERROR [STDERR] 	at
com.vocalocity.hdap.appserver.HDAPServlet.doRequest(HDAPServlet.java:77)
2006-11-16 10:14:59,514 ERROR [STDERR] 	at
com.vocalocity.hdap.appserver.HDAPServlet.doGet(HDAPServlet.java:63)
2006-11-16 10:14:59,530 ERROR [STDERR] 	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
2006-11-16 10:14:59,530 ERROR [STDERR] 	at
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
2006-11-16 10:14:59,530 ERROR [STDERR] 	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:252)
2006-11-16 10:14:59,530 ERROR [STDERR] 	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:173)
2006-11-16 10:14:59,545 ERROR [STDERR] 	at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilte
r.java:96)
2006-11-16 10:14:59,561 ERROR [STDERR] 	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:202)
2006-11-16 10:14:59,561 ERROR [STDERR] Caused by:
org.postgresql.util.PSQLException: A CallableStatement function was
executed and the return was of type java.sql.Types=12 however type
java.sql.Types=0 was registered.
2006-11-16 10:14:59,561 ERROR [STDERR] 	at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdb
c2Statement.java:387)
2006-11-16 10:14:59,577 ERROR [STDERR] 	at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Stateme
nt.java:346)
2006-11-16 10:14:59,577 ERROR [STDERR] 	at
org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.execute(Wrapped
PreparedStatement.java:209)
2006-11-16 10:14:59,577 ERROR [STDERR] 	at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Lja
va.lang.Object;)Ljava.lang.Object;(Unknown Source)
2006-11-16 10:14:59,577 ERROR [STDERR] 	at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)L
java.lang.Object;(Unknown Source)
2006-11-16 10:14:59,592 ERROR [STDERR] 	at
com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(Prepared
StatementLogProxy.java:62)
2006-11-16 10:14:59,592 ERROR [STDERR] 	at $Proxy68.execute()Z(Unknown
Source)
2006-11-16 10:14:59,592 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(Sql
Executor.java:289)
2006-11-16 10:14:59,592 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecute
Query(ProcedureStatement.java:34)
2006-11-16 10:14:59,608 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:173)
2006-11-16 10:14:59,608 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForObject(GeneralStatement.java:104)
2006-11-16 10:14:59,608 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:561)
2006-11-16 10:14:59,608 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:536)
2006-11-16 10:14:59,623 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSes
sionImpl.java:93)
2006-11-16 10:14:59,623 ERROR [STDERR] 	at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClie
ntImpl.java:70)
2006-11-16 10:14:59,623 ERROR [STDERR] 	at
com.vocalocity.hosted.appserver.config.IbatisConfigurationLoader.getRoot
Document(IbatisConfigurationLoader.java:60)
2006-11-16 10:14:59,623 ERROR [STDERR] 	at
com.vocalocity.hosted.appserver.config.ConfigurationManager.getRootDocum
ent(ConfigurationManager.java:38)
2006-11-16 10:14:59,639 ERROR [STDERR] 	at
jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Lja
va.lang.Object;)Ljava.lang.Object;(Unknown Source)
2006-11-16 10:14:59,639 ERROR [STDERR] 	at
jrockit.reflect.InitialMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lan
g.Object;)Ljava.lang.Object;(Unknown Source)
2006-11-16 10:14:59,639 ERROR [STDERR] 	at
java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)L
java.lang.Object;(Unknown Source)
2006-11-16 10:14:59,655 ERROR [STDERR] 	at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(
AopUtils.java:287)
2006-11-16 10:14:59,655 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinp
oint(ReflectiveMethodInvocation.java:181)
2006-11-16 10:14:59,655 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:148)
2006-11-16 10:14:59,670 ERROR [STDERR] 	at
org.springframework.transaction.interceptor.TransactionInterceptor.invok
e(TransactionInterceptor.java:96)
2006-11-16 10:14:59,670 ERROR [STDERR] 	at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(Ref
lectiveMethodInvocation.java:170)
2006-11-16 10:14:59,670 ERROR [STDERR] 	at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAo
pProxy.java:176)