Oracle PL/SQL calls Oracle stored procedures with input and output parameters in Java

Source: Internet
Author: User

Just note that the output parameter is registered with the Registeroutparameter method inside the CallableStatement.

Stored procedures:

Import java.sql.CallableStatement;
Import java.sql.Connection;
Import Java.sql.DriverManager;
Import java.sql.PreparedStatement;
Import java.sql.SQLException;
Import Java.sql.Types;

Calling Oracle's stored procedures in Java
public class Javacallpro {

public static void Main (string[] args) {
String driver= "Oracle.jdbc.driver.OracleDriver";
String url= "JDBC:ORACLE:THIN:@127.0.0.1:1521:ORCL";
String user= "Scott";
String password= "Ztoracle";
try {
Class.forName (driver);
Connection c=drivermanager.getconnection (URL, user, password);
CallableStatement Cs=c.preparecall ("{Call My_pro (?,?,?)}");
Cs.setstring (1, "9527");
Cs.registeroutparameter (2, Types.varchar);
Cs.registeroutparameter (3, Types.varchar);
Cs.execute ();
System.out.println (cs.getstring (2));
} catch (ClassNotFoundException e) {
throw new RuntimeException ();
} catch (SQLException e) {

}
}

}

Oracle PL/SQL calls Oracle stored procedures with input and output parameters in Java

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.