Two ways to invoke Oracle function in Java ____c++

Source: Internet
Author: User
Tags stmt
1.

preparedstatement stmt =conn.preparestatement ("Select Pkg.fun" (?) from dual ");

Stmt.setlong (1,123);

Result rs = Stmt.executequery ();

if (rs.next) {return

   rs.getdouble (1);

}

2.

callablestatement Stmt=conn.preparecall ("{=call pkg.fun (?)}");

Stmt.registeroutparameter (1,java.sql.types.double);

Stmt.setlong (2,123);

if (!stmt.execute ()) {return

   stmt.getdouble (1);

}

The information found below from the Web

callablestatement.execute ()

returns a Boolean value ... Returns

true if the first value returned is ResultSet, otherwise returns false ...

finally understand why the execution success also returns false.
Both ways are fine, but the second way looks normal.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.