Spring StoredProcedure for Oracle cursor

Spring StoredProcedure for Oracle cursorhttp://forum.springsource.org/archive/index.php/t-24915.htmlPDAViewFullVersion:SqlReturnResultSetvs.SqlOutParameter  lvmMay12th,2006,12:33PMIspentsometimeyest

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

http://forum.springsource.org/archive/index.php/t-24915.html

PDA

View Full Version : SqlReturnResultSet vs. SqlOutParameter


 

 

lvm
May 12th, 2006, 12:33 PM

I spent some time yesterday trying to call an Oracle stored procedure(function) using the org.springframework.jdbc.object.StoredProcedure class and thought I share what I found.

I got some code from a co-worker that was doing the same thing, but connecting to MS SQLServer. I didn’t have his stored proc to look at for clues.

He was using SqlReturnResultSet:

declareParameter(new SqlReturnResultSet(“rs” new MessageResultExtractor(msgList)));

My Oracle stored proc accepts no inputs and returns a cursor. When I tried to use the code above I kept getting an error like “invalid number or type of arguments”. I looked at the API for SqlReturnResultSet, which states that it is: “Subclass of SqlOutParameter”. But looking at the inheritance stack it shows that it does not! So I figured I needed to declare an SqlOutParameter, which conveniently accepts a ResultSetExtractor. So I used:

declareParameter(new SqlOutParameter(“rs”, OracleTypes.CURSOR, new MessageResultExtractor(msgList))); and it worked!

Note that I had to use the OracleTypes.CURSOR, which I wasn’t sure would work.

I don’t know if there are ways of getting a resultset from an oracle stored procedure other than a cursor, or maybe there’s a way to use SqlReturnResultSet with a cursor, but the SqlOutParameter worked for me.


 

trisberg
May 15th, 2006, 10:50 AM

What you are doing is the best solution. The way Oracle works is different from SQL Server since a stored procedure has to return the cursor/resultset as an explicitly declared ref-cursor out parameter. There is no such restriction in SQL Server so the way we retreive the resultset using standard JDBC API calls is very different for Oracle as compared to SQL Server.

 ==========

注意:

在申明参数时应该按照sp的参数顺序,否则会报错:

PLS-00306: wrong number or types of arguments in call to  

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/164516.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 64位Win10 Modelsim破解及证书LICENSE.TXT无法生成解决方法

    64位Win10 Modelsim破解及证书LICENSE.TXT无法生成解决方法将patch_dll.bat和MentorKG.exe放到安装目录的win64目录下安装时一路点YES,可以不用重启。方法1:找到安装目录下win64的mgls64.dll,取消只读         打开cmd(快捷键:super+R,输入cmd)         输入E:(安装磁盘)回车         输入cd :/Modelsim/win64(安装目录中的wi

    2022年5月24日
    100
  • SAP IDES、DEV、QAS、PRD都是什么含义/SAP实施方法分几步【转】[通俗易懂]

    SAP IDES、DEV、QAS、PRD都是什么含义/SAP实施方法分几步【转】[通俗易懂]1SAPIDES、DEV、QAS、PRD都是什么含义?2IDES详细介绍3SAP实施方法分几步?答:1SAP系统的IDES、DEV、QAS、PRD分别是其演示练习、开发、质量保证、生产系统。其中:IDES:InternetDemonstrationandEvaluationSystem,交互式演示与教育系统DEV:DevelopmentS…

    2022年6月28日
    27
  • R与RStudio的详细安装教程(有每一步的详细教程!!!!)

    R与RStudio的详细安装教程(有每一步的详细教程!!!!)R与RStudio的详细安装教程(如果下面的博客没有能解决你的问题或者你还有其他关于计算机方面的问题需要咨询可以加博主QQ:1732501467)R是RStudio的前提,首先安装R,才能安装RStudio。安装R教程总共分为三步:一、下载R安装包二、安装R三、打开R安装RStudio,总共分为两步:一、安装RStudio二、测试RStudio是否安装成功R安装开始:一、下载R安装包1.下载网址:https://mirrors.tuna.tsinghua.edu.cn/CRAN/

    2022年6月26日
    49
  • pycharm中pyqt5使用方法_pycharm安装pyqt5失败

    pycharm中pyqt5使用方法_pycharm安装pyqt5失败1.安装第pyqt5pipinstallpyqt52.QtDesigner安装和使用pipinstallpyqt5-tools3.UI文件转换成py文件$FileName$-o$FileNameWithoutExtension$.py-x4.将QRC资源文件转换成py文件$FileName$-o$FileNameWithoutExtension$_rc.py5.测试5.1新建项目5.2新建UI界面5.3将QT设计师保

    2022年8月29日
    2
  • 初学者的20个爬虫经典案例视频_李昌钰水门事件20集大经典案例

    初学者的20个爬虫经典案例视频_李昌钰水门事件20集大经典案例初学者入门爬虫的经典案例!

    2022年10月10日
    3
  • 什么是GMM算法_bs模型公式

    什么是GMM算法_bs模型公式1.高斯模型与高维高斯模型介绍高斯模型也就是正态分布模型,该模型最早可见于我们的高中数学教材中。闻其名知其意,正态分布是自然界中普遍存在的一种分布。比如,考试成绩,人的智力水平等等。都是大致呈现为正态分布。其概率密度函数为其中参数为μ,σ2,都是一维标量。对于高维高斯模型,与一维类似,只是自变量变成了多维,是一个向量。其概率密度函数为其中参数为μ…

    2025年6月6日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号