Announcement Announcement Module
Collapse
No announcement yet.
ResultSets from sql server 2005 and ibatis Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ResultSets from sql server 2005 and ibatis

    Hi!
    I am using ibatis in my persistence layer.
    A problem occured to me when I tried to call the procedure which returns multiple resultsets.

    Following is the source code!

    sp:
    Code:
    CREATE PROCEDURE [dbo].[Procedure_EmpInfoSearch] @sqlStr2 varchar(6000)	
    AS
    BEGIN
    declare @sqlStr1 varchar(2000),@sqlStr varchar(8000),@P1 int
    	SET NOCOUNT ON;
    	set @sqlStr1='select * from employee,department,positionInfo,nationalInfo where employee.departID=department.departID and employee.positionID=positionInfo.positionID and employee.nationalID=nationalInfo.nationalID'
    	set @sqlStr=@sqlStr1+@sqlStr2
    exec sp_cursoropen @P1 output,@sqlStr
    exec sp_cursorfetch @P1
    exec sp_cursorclose @P1
    set nocount off
    END
    ibatis configuration document:
    Code:
    <parameterMap id="EmpInfoSearchParameters" class="java.util.HashMap">
            <parameter property="result" jdbcType="CURSOR" javaType="java.sql.ResultSet" mode="OUT"/>
            <parameter property="sqlStr" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
        </parameterMap>
    
     	<procedure id="empInfoSearchProc" resultClass="Employee"  parameterMap="EmpInfoSearchParameters" >
             {? = call Procedure_EmpInfoSearch(?)}
     	</procedure>

    Java code:

    Code:
    public List<Employee> getEmployeeList(String sqlStr)
    	{
    		HashMap<String, String> parameters = new HashMap<String, String>();
            parameters.put("sqlStr", sqlStr);
    		List<Employee> employeeList=(List<Employee>)(getSqlMapClientTemplate().queryForList("empInfoSearch.empInfoSearchProc", parameters));
    		return employeeList;
    	}


    The error:

    org.springframework.jdbc.UncategorizedSQLException : SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
    --- The error occurred in ibatis/config/empInfoSearch.xml.
    --- The error occurred while applying a parameter map.
    --- Check the empInfoSearch.EmpInfoSearchParameters.
    --- Check the statement (update procedure failed).
    --- Cause: java.lang.NullPointerException; nested exception is com.ibatis.common.jdbc.exception.NestedSQLExceptio n:
    --- The error occurred in ibatis/config/empInfoSearch.xml.
    --- The error occurred while applying a parameter map.
    --- Check the empInfoSearch.EmpInfoSearchParameters.
    --- Check the statement (update procedure failed).
    --- Cause: java.lang.NullPointerException


    Does anybody know what's wrong with these codes?
    Last edited by betty; Nov 2nd, 2009, 11:44 PM.
Working...
X