DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    tammy Guest

    call stored procedure with parameter


    Hi,
    everyone.
    Could you show me how can I pass a parameter to call a stored procedure
    ? I have been successfully to do it without any parameters as following:

    CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");

    but, what can I do with parameters passing?

    Thank you!






  2. #2
    Madhav Guest

    Re: call stored procedure with parameter


    "tammy" <yan.zhang@unitedchambers.com> wrote:
    >
    >Hi,
    > everyone.
    > Could you show me how can I pass a parameter to call a stored procedure
    >? I have been successfully to do it without any parameters as following:
    >
    >CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");
    >
    >but, what can I do with parameters passing?
    >
    > Thank you!


    Hi Tammy ,
    I'll give you an example to explain :

    String s = new String({?= call multiply[?,?]});

    CallableStatement cs = dbconn.prepareCall(s);
    cs.setInt(2, 10);
    cs.setInt(3, 30);

    cs.registerOutParameter(1 ,NUMBER); // NUMBER is a sqlType
    ResultSet rs = cs.executeUpdate;
    rs.getInt(1);

    this is how it goes.

    Thanks
    Madhav




    >
    >
    >



  3. #3
    syed Guest

    Re: call stored procedure with parameter


    Hi tommy,
    Read JDBC part of java tutorial. very good one.

    Cheers
    syed zulfiqar


    "Madhav" <djlintls@hotmail.com> wrote:
    >
    >"tammy" <yan.zhang@unitedchambers.com> wrote:
    >>
    >>Hi,
    >> everyone.
    >> Could you show me how can I pass a parameter to call a stored procedure
    >>? I have been successfully to do it without any parameters as following:
    >>
    >>CallableStatement cs = dbconn.prepareCall("{call qGetProduct}");
    >>
    >>but, what can I do with parameters passing?
    >>
    >> Thank you!

    >
    >Hi Tammy ,
    >I'll give you an example to explain :
    >
    >String s = new String({?= call multiply[?,?]});
    >
    >CallableStatement cs = dbconn.prepareCall(s);
    >cs.setInt(2, 10);
    >cs.setInt(3, 30);
    >
    >cs.registerOutParameter(1 ,NUMBER); // NUMBER is a sqlType
    >ResultSet rs = cs.executeUpdate;
    >rs.getInt(1);
    >
    >this is how it goes.
    >
    >Thanks
    >Madhav
    >
    >
    >
    >
    >>
    >>
    >>

    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links