Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SQL Server Stored Procedures

SQL Server Stored Procedures

SQL Server Stored Procedures


I am trying to run a SQL Server stored procedure from a JSP page and just cant seem to figure out how to do it. I am communicating fine with the d/base and running standard SQL queries with no worries so I think it is just the syntax I am a bit unsure of.

I am a little confused over callable statements etc and also how to obtain a recordset from a stored procedure.

At present my working code looks like this:

Driver MM_driver = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection myConn = DriverManager.getConnection("jdbc:weblogic:mssqlserver4:web_test@mydatabase",MM_editUserName,MM_editPassword);
    Statement stmt = myConn.createStatement();//(MM_editQuery.toString());
    ResultSet myResultSet = stmt.executeQuery("select * from test_table");
    if (myResultSet != null)

            while (myResultSet.next()) {
        String eid = myResultSet.getString("id");
hello<%= eid %>


All help and suggestions most appreciated in my time of need.


"Creativity is the ability to introduce order into the randomness of nature." Eric Hoffer

Visit me at http://www.dfodesign.co.nz

RE: SQL Server Stored Procedures


1) create a callable statement object :

CallableStatement cstmt = myConn.prepareCall("{? = call procedurename(arg1,arg2,...) }");

2) register OUT parameters. see doc for CallableStatement

3) set IN parameters.

ex : cstmt.setInt(index of parameter in the list of arguments, value (here an int))

much setXXX methods exists for all SQL types (String, Double...)

3) execute query



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close