Java로 JTDS를 사용하여 Microsoft SQL 데이터베이스에 연결하고 있습니다. 데이터베이스에 완벽하게 연결할 수 있습니다. 그러나 아래 코드를 실행하면 "get_queue_items '저장 프로 시저를 찾을 수 없습니다."라는 오류가 발생합니다. 전 접두사 'dbo'시도했습니다. 그러나 저장 프로 시저 이름에 오류가 계속 발생합니다. 또한 참조 용으로 실제 저장 프로 시저를 포함 시켰습니다. JTDS (Java/MSSQL) - 저장 프로 시저를 찾을 수 없습니다.
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 자바에 새로운 해요,하지만 어떤 도움을 주시면 감사하겠습니다.
편집 : 여전히 같은 오류 get_queue_items '
편집 2'저장 프로 시저를 찾을 수 없습니다 '지고, 크리스티안의 조언에 따라 저장 프로 시저 변경 : 아직도 작동하지 않습니다 - 데이터베이스 연결도 좋은 것입니다.
위와 똑같이 프로 시저를 수정했지만 여전히 동일한 오류가 발생합니다. – MichaelICE
** 연결 **이 데이터베이스 [테스트]에 연결되어 있습니까? –
이 CallableStatement 행을 수정하면 proc = connection.prepareCall ("{[test]. [dbo]. [get_queue_items] (1)}"); 매개 변수를 제거하면 오류가 발생합니다. 오류 : 프로 시저 또는 함수 'get_queue_items'가 제공되지 않은 '@last_queue_entry'매개 변수를 필요로합니다. – MichaelICE