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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 80
HSSFWorkbook cannot be resolved error 10 50
Spring Framework HTTPSession management 1 23
Oracle SQL syntax check  without executing 6 36
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now