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 snehalkgandhi <sn...@jpmchase.com> on 2008/02/04 16:51:40 UTC

Error Calling SP on SQL Server

Hi,
  I'm trying to call an Stored Procedure(SP) in SQL Server 8.0. The SP takes
in 2 parameters and returns a resultset. I tried the searching for the
jdbcType="??" for the SQL Server DB. For Oracle we have ORACLECURSOR and I
don't know what is it for SQL Server.

I'm getting 2 errors.. 
    1st Error : Error Message when I try to build the project.
Err. Msg : Caused by: com.ibatis.common.exception.NestedRuntimeException:
Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error
parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException:
Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause:
com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause:
org.xml.sax.SAXParseException: Attribute "resultMap" must be declared for
element type "parameter".

    2nd Error : If I remove the resultMap="loginresult" from the OUT
Parameter of parameterMapid="rrParameters", then the project build fine but
throws an Exception at runtime saying the SQL Type is not supported by the
driver.

Can someone please help me on this and being stuck out here for the last 8
hours..

Code :
	<resultMap id="loginresult" class="com.rr.beans.RRBean">
		<result property="userId" column="userid" />
		<result property="firstName" column="firstname" />
		<result property="lastName" column="lastname" />
	</resultMap>

	<parameterMap id="rrParameters" class="Map">
		<parameter property="userId" jdbcType="VARCHAR" mode="IN" />
		<parameter property="password" jdbcType="VARCHAR" mode="IN" />
		<parameter property="rrLogBean" jdbcType="refcursor"
			javaType="java.sql.ResultSet" mode="OUT" resultMap="loginresult" />
	</parameterMap>

	<procedure id="rrlogin" parameterMap="rrParameters"
		resultMap="loginresult">
		{call i031846.rr_login(?, ?, ?)}
	</procedure>

Java Code :
    	Map parameters = new HashMap();
    	logInfo("IN DAO - rrLoginBean.getUserId() : " +
rrLoginBean.getUserId());
    	logInfo("IN DAO - rrLoginBean.getPassword() : " +
rrLoginBean.getPassword());
    	parameters.put("userId", rrLoginBean.getUserId());
    	parameters.put("password", rrLoginBean.getPassword());
             getSqlMapClientTemplate().update(keyValue, obj);
             rrLogin = (RRLoginBean)parameters.get("rrLoginBean");

Thanks in Advance
Snehal Gandhi
-- 
View this message in context: http://www.nabble.com/Error-Calling-SP-on-SQL-Server-tp15269015p15269015.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Error Calling SP on SQL Server

Posted by nmansur <nm...@cisco.com>.
I m having similar problem did you find the solution for this ? 
pls share

Tx,
--Naveen


snehalkgandhi wrote:
> 
> Hi,
>   I'm trying to call an Stored Procedure(SP) in SQL Server 2000. The SP
> takes in 2 parameters and returns a resultset. I tried the searching for
> the jdbcType="??" for the SQL Server DB. For Oracle we have ORACLECURSOR
> and I don't know what is it for SQL Server.
> 
> I'm getting 2 errors.. 
>     1st Error : Error Message when I try to build the project.
> Err. Msg : Caused by: com.ibatis.common.exception.NestedRuntimeException:
> Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error
> parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException:
> Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause:
> com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause:
> org.xml.sax.SAXParseException: Attribute "resultMap" must be declared for
> element type "parameter".
> 
>     2nd Error : If I remove the resultMap="loginresult" from the OUT
> Parameter of parameterMapid="rrParameters", then the project build fine
> but throws an Exception at runtime saying the SQL Type is not supported by
> the driver.
> 
> Can someone please help me on this and being stuck out here for the last 8
> hours..
> 
> Code :
> 	<resultMap id="loginresult" class="com.rr.beans.RRBean">
> 		<result property="userId" column="userid" />
> 		<result property="firstName" column="firstname" />
> 		<result property="lastName" column="lastname" />
> 	</resultMap>
> 
> 	<parameterMap id="rrParameters" class="Map">
> 		<parameter property="userId" jdbcType="VARCHAR" mode="IN" />
> 		<parameter property="password" jdbcType="VARCHAR" mode="IN" />
> 		<parameter property="rrLogBean" jdbcType="refcursor"
> 			javaType="java.sql.ResultSet" mode="OUT" resultMap="loginresult" />
> 	</parameterMap>
> 
> 	<procedure id="rrlogin" parameterMap="rrParameters"
> 		resultMap="loginresult">
> 		{call i031846.rr_login(?, ?, ?)}
> 	</procedure>
> 
> Java Code :
>     	Map parameters = new HashMap();
>     	logInfo("IN DAO - rrLoginBean.getUserId() : " +
> rrLoginBean.getUserId());
>     	logInfo("IN DAO - rrLoginBean.getPassword() : " +
> rrLoginBean.getPassword());
>     	parameters.put("userId", rrLoginBean.getUserId());
>     	parameters.put("password", rrLoginBean.getPassword());
>              getSqlMapClientTemplate().update(keyValue, obj);
>              rrLogin = (RRLoginBean)parameters.get("rrLoginBean");
> 
> Thanks in Advance
> Snehal Gandhi
> 

-- 
View this message in context: http://www.nabble.com/Error-Calling-SP-on-SQL-Server-tp15269015p21073818.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.