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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
couple of eclipse 5 52
servlet example 11 56
how to see all occupied ports on windows 10 laptop 15 82
Html split(text) 2 26
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

735 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