Home > Database > Mysql Tutorial > java调用oracle存储过程

java调用oracle存储过程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:03:42
Original
1160 people have browsed it

package com.hyq.src; import java.sql.*; import java.sql.ResultSet; public class TestProcedureOne { public TestProcedureOne() { } public static void main(String[] args ){ String driver = "oracle.jdbc.driver.OracleDriver"; String str

    package com.hyq.src;

    import java.sql.*;

    import java.sql.ResultSet;

    public class TestProcedureOne {

    public TestProcedureOne() {

    }

    public static void main(String[] args ){

    String driver = "oracle.jdbc.driver.OracleDriver";

    String strUrl = "jdbc:oracle:thin:@127.0.0.1:1521: hyq ";

    Statement stmt = null;

    ResultSet rs = null;

    Connection conn = null;

    CallableStatement cstmt = null;

    try {

    Class.forName(driver);

    conn =  DriverManager.getConnection(strUrl, " hyq ", " hyq ");

    CallableStatement proc = null;

    proc = conn.prepareCall("{ call HYQ.TESTA(?,?) }");

    proc.setString(1, "100");

    proc.setString(2, "TestOne");

    proc.execute();

    }

    catch (SQLException ex2) {

    ex2.printStackTrace();

    }

    catch (Exception ex2) {

    ex2.printStackTrace();

    }

    finally{

    try {

    if(rs != null){

    rs.close();

    if(stmt!=null){

    stmt.close();

    }

    if(conn!=null){

    conn.close();

    }

    }

    }

    catch (SQLException ex1) {

    }

    }

    }

    }

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template