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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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
Protect jar file - windows app 2 64
JavaScript/Java - Changing an image background color 4 75
eclipse shortcuts 9 62
Java program running SQL query 5 37
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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 “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

789 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