running a MS SQL server 2000 stored procedure

Posted on 2004-08-20
Last Modified: 2010-03-31

I have a table called alpha

I have a store procedure on it alphaADD

EXEC alphaADD 'abc123','1','5'

How do I execute this procedure from a java code that takes three values in text boxes and passes them as an argument

Question by:anshuma
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 35

Expert Comment

ID: 11854198
Hi anshuma,

you need a CallableStatement to call a stored procedure. Take a look here for sample code and instruction how to do it:


Accepted Solution

beermequik earned 250 total points
ID: 11854411
Exception ex = null
Connection dbCon;

try {
    dbCon = // your connection code

    CallableStatement stmt = dbCon.prepareCall("EXEC alphaADD ?, ?, ?");

    int paramIndex = 0;
    stmt.setString(++paramIndex, //textbox1 value);
    stmt.setString(++paramIndex, //textbox2 value);
    stmt.setString(++paramIndex, //textbox3 value);

} catch (SQLException sqlE) {
    ex := sqlE;
} finally {
    // guarantee you close the connection
    if (ex != null) {
        // process exception or rethrow it.


Expert Comment

ID: 11854436
oops...done forget to initialize dbCon to null when its declared.

Featured Post

Technology Partners: 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
How to get all the API from website? 11 130
Why my table column Id is not passed to java object? 4 46
Is there a simpler dropbox system? 10 44
Java array sort 10 35
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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

730 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