日期:2014-05-17  浏览次数:20796 次

java中调用oracle中的存储过程失败?

java中的代码:
----------------------------------------------
import java.sql.*;
import java.sql.Types;

public class TestProcedure {
    
    Connection conn = null;
    CallableStatement callStmt = null;
    
    public static void main(String[] args) {
        TestProcedure tp = new TestProcedure();
        tp.connect();
        tp.procExec();
        tp.closeConnect();
    }
      
    private void connect() {
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            System.out.println("获取驱动成功!");
        } catch (ClassNotFoundException e) {
            System.out.println("创建数据库服务器驱动失败!");
            e.printStackTrace();
        }
        try {
            conn  =    DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:myoracle", "scott", "tiger");
        System.out.println("数据库连接成功!");
        } catch (SQLException e) {
        System.out.println("连接数据库失败,请联系管理员!");
        e.printStackTrace();
        this.closeConnect();
        }
    }
    
    //关闭,可以略过!
    private void closeConnect() {
        if (null != this.conn) {
        try {
           conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
            this.conn = null;
        }
    if (null != this.callStmt) {
        try {
            this.callStmt.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }