首页 > 解决方案 > 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存储过程提示找不到存储过程怎么办

标签: javasql-servereclipsesql-server-2008stored-procedures

解决方案


推荐阅读