mybatis calls the sqlserver stored procedure result set to output the cursor

Recently, the project uses sqlserver as the database server. When using mybatis to call the stored procedure, an error is reported, as follows:



The mybatis mapper is configured as follows:

  After debugging, it was found that the parameter resultList jdbcType=CURSOR was misconfigured. Looking at the source code, it was found that the CURSOR of mybatis JdbcType only supports Oracle, as shown in the following figure:



 Because it is the first time to use MSSQL, the thinking of the writing process is still in Oracle, and later found that MSSQL does not need to use cursors to return the result set like Oracle. The purpose of using cursor varying output is to obtain an open value when calling a procedure in MSSQL cursor.

Note: This refers to the cursor processed in MSSQL, not the recordset cursor obtained by your client program from the server.
In other words, the JAVA client cannot handle the cursor brought out by varying output.
In fact, as long as a query statement is set in the stored procedure, after the JAVA program calls the stored procedure, a recordset can be obtained, and the recordset can be processed in the program, similar to the cursor processing in MSSQL.

 

Finally, after modifying the mapper configuration file, the program executes normally, as shown in the following figure:


 

 


 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326977158&siteId=291194637