gpt4 book ai didi

java - JTDS (Java/MSSQL) - 找不到存储过程

转载 作者:行者123 更新时间:2023-12-02 08:05:56 25 4
gpt4 key购买 nike

我正在使用 JTDS 和 Java 连接到 Microsoft SQL 数据库。我能够完美连接到数据库。但是,当我运行下面的代码时,出现错误“找不到存储过程'get_queue_items'”。我尝试过添加前缀“dbo”。到存储过程名称,但是我仍然收到错误。我还提供了实际的存储过程以供引用。

try {
// Prepare and call the stored procedure
CallableStatement proc = connection.prepareCall("{call get_queue_items(?) }");

// Register the ResultSet
proc.registerOutParameter(1, java.sql.Types.INTEGER);

// Register Input Parameters
proc.setInt("@last_queue_entry", 1);

// Execute the stored procedure
proc.execute();

// If we have a ResultSet
if (proc.getMoreResults()) {
ResultSet rs = proc.getResultSet();
if (rs.next()) {
// to complete...
}
}
}
catch(Exception ex)
{
System.out.println("Error: " + ex.getMessage());
}

存储过程:

USE [test]
GO
/****** Object: StoredProcedure [dbo].[get_queue_items] Script Date: 11/17/2011 11:43:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[get_queue_items] @qid int OUT, @last_queue_entry int as
-- select all the new records out of the main table into a temp table
-- the temp table is what we will use to process

select @qid = qid from test.[dbo].que_items
where qid > @last_queue_entry

我是 JTDS 和 Java 的新手,所以很可能是我的错,但如果有任何帮助,我们将不胜感激。

编辑:按照克里斯蒂安的建议更改了存储过程,但仍然收到相同的错误“找不到存储过程'get_queue_items'”

编辑 2:仍然无法正常工作 - 数据库连接似乎也很好。

最佳答案

今天我遇到了同样的问题,在我看来,jTDS 实现中有一个错误。对我来说,解决方案是过程重命名并删除所有下划线符号(在您的情况下是 getQueueItems(?) )。试试吧,我想对你一定有帮助。

关于java - JTDS (Java/MSSQL) - 找不到存储过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8169687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com