JTDSとJavaを使用して、MicrosoftSQLデータベースに接続しています。データベースに完全に接続できます。ただし、以下のコードを実行すると、「ストアドプロシージャ'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に慣れていないので、私が責任を負っている可能性がありますが、助けていただければ幸いです。
編集:Cristianのアドバイスに従ってストアドプロシージャを変更しましたが、同じエラーが発生します'ストアドプロシージャが見つかりませんでした'get_queue_items'
編集2:まだ機能していません-データベース接続も問題ないようです。