Acquiring Resultset from CallableStatement

Posted on 2004-09-18
Last Modified: 2006-11-17
Hi Experts...

I am trying to acquire a ResultSet from CallableStatement...

ResultSet rst;
CallableStatement cstmt;

String strSQL = "(call MY_PROC(?))";
String MyParam = "28900003";

cstmt = conn.prepareCall(strSQL, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
cstmt.setString(1, MyParam);
rst = (ResultSet) cstmt.getObject(1);

Here is my MS SQL Stored Procedure :

@MyParam varchar(20)
SELECT Field2,Field3 FROM Orders WHERE Field1=@MyParam

However I am getting this error on line cstmt.execute()...

java.sql.SQLException: [aveConnect][JDBC SQL Server Driver]  Line 1: Incorrect s
yntax near '28900003'.
        at net.avenir.jdbc2.k.q(
        at net.avenir.jdbc2.k.eb(
        at net.avenir.jdbc2.k.ib(
        at net.avenir.jdbc2.k.query(
        at net.avenir.jdbc2.a.b(
        at net.avenir.jdbc2.y.a(
        at net.avenir.jdbc2.y.execute(

Hope you could help me...   Thanks...   =)
Question by:aris_datuin
  • 2
LVL 86

Expert Comment

ID: 12091700
That looks to me like an incorrect syntax problem in the SP itself, and hence is not a Java problem yet

Accepted Solution

sbockelman earned 100 total points
ID: 12093003

You need to register an OUT paramter to hold the rs.

You need to use {} not () around your proc.

Read this article for details:

You may need to adjust some of the things for SQLServer vs. Oracle, but principles are similar.


Author Comment

ID: 12094650
Hi sbockelman...

This line solved my problem :

            You need to use {} not () around your proc.

Thanks..  =)

Expert Comment

ID: 12095763

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java stored proc example 9 45
Java: How do I open the default windows program for a given file type 3 39
jsp insert to database example 2 47
collection output issue 9 37
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question