• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

how to call stored procedures using ADO/WFC?

In my J++ application ,i want to call a stored procedure in SQL server and get the output/return value using ADO/WFC,i tried several times using Connection and Command object but failed,can you help me? thank you!
0
Mike2000
Asked:
Mike2000
1 Solution
 
JodCommented:
What errors are you getting and for what data types? Have you tried something like this simple example?

Sql is:


   create proc SimpleSQL

     @i1  int output,
      @i2  int output,
       @i3  int output,
        @i4  int output
     as

   select @i1 = 555,
          @i2 = 666,
          @i3 = 777,
          @i4 = 888

    return 999


Java is:

  CallableStatement stmt =
    conn.prepareCall(" { ? = call simpleSQL(?, ?, ?, ?) }");

  stmt.registerOutParameter(1, Types.SMALLINT);

  for(k=2;k<=5;k++){
    stmt.setInt(k,k * 100);
    stmt.registerOutParameter(k, Types.INTEGER);
  }

  int count = stmt.executeUpdate();

  System.out.println(count);

Then use stmt.getInt(<parameterIndex>) to get the various integer data after this...
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now