java - Eclipse调用sqlsever存储过程提示找不到存储过程
问题描述
我在sqlserver上新建了一个可以在profiler上运行的存储过程,但是当我用eclipse调用存储过程时,提示找不到存储过程。如果您能给我一点帮助,我将不胜感激 public class TestID {
public static void main(String[] args) {
// TODO Auto-generated method stub
DBUtil db = new DBUtil();
Connection conn = null;
CallableStatement cstmt =null;
try{
conn = db.getConnection();
cstmt = conn.prepareCall("{call dbo.GetSeqVal(?)}");
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
cstmt.execute();
int count=cstmt.getInt(1);
System.out.println(count);
}catch (Exception e) {
e.printStackTrace();
} finally {
db.closeAll();
}
}
下面是我在sqlserver中创建的存储过程,以及调用的statememt
USE [test]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[SP_GetSeqVal]
@result int output
as
begin
declare @NewSeqValue int
set NOCOUNT ON
insert into SEQ_SERIAL_NO(seqval) values ('a')
set @NewSeqValue = scope_identity()
set @NewSeqValue = Convert(char(4),Getdate(),112) + right('000000'+CAST(scope_identity() AS varchar(5)),5)
delete from SEQ_SERIAL_NO WITH (READPAST)
set @result=@NewSeqValue
return @NewSeqValue
end
Declare @NewSeqVal int,@myResult int
Exec @NewSeqVal=GetSeqVal @myResult output
Print @myResult
print @NewSeqVal
调用后会出现结果,如果eclipse调用sqlsever存储过程提示找不到存储过程怎么办
解决方案
推荐阅读
- python - Python 通过套接字读取和发送文件
- python - python中大型数据集存储的最佳方法?
- java - 使用注释@CsvDate 读取 dd/mm/yy(2 位数年份)中的 csv 列日期值
- android - 按下按钮时出现错误
- python - KivyMD 包文件中的 Buildozer SyntaxWarning
- android - 如何将 EditText 值添加到 Kotlin 中的 ArrayList?
- python - 跨列对 pandas 数据框应用多项质量检查
- google-cloud-platform - Google Dataproc pySpark 在公共 BigQuery 表上运行缓慢
- git - GitLab:报告用户由于不活动而将删除 git 分支
- python - 如何解压缩镶木地板文件?