java 存储过程调用

 

import java.sql.*;

public class jdbc_prc {

  
public static void main(String args[]) {

    
try {
      Class.forName(
"oracle.jdbc.driver.OracleDriver");
    }
 catch (Exception e) {
      System.out.println(
"异常"+e.getMessage());
      System.exit(
1);
    }


    Connection conn 
= null;
    Statement stmt 
= null;
    ResultSet rset 
= null;
    ResultSet rs 
= null;
    
//PreparedStatement pstmt;
    String sql;
    
try {
      conn 
= DriverManager.getConnection(
          
"jdbc:oracle:thin:@127.0.0.1:1521:ccxe""scott""test");

        
//conn.prepareStatement
        CallableStatement myCallableStatement=conn.prepareCall(
            
"{call update_salgrade(?,?,?)}"
        );
        myCallableStatement.setInt(
1,7);
        myCallableStatement.setInt(
2,8000);
        myCallableStatement.setInt(
3,9000);
        myCallableStatement.execute();
        myCallableStatement.close();


      conn.close(); 
//关闭数据库连接
      conn = null;
    }
 catch (SQLException e) {
      System.out.println(
"Darn! A SQL error: " + e.getMessage());
    }
 finally {
      
if (rset != null)
        
try {
          rset.close();
        }
 catch (SQLException ignore) {
        }

      
if (stmt != null)
        
try {
          stmt.close();
        }
 catch (SQLException ignore) {
        }

      
if (conn != null)
        
try {
          conn.close();
        }
 catch (SQLException ignore) {
        }

    }

  }

}


 

posted on 2012-03-08 23:41 snowhill 阅读(102) 评论(0)  编辑 收藏 引用 所属分类: java


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2008年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

导航

公告

又一年...........

留言簿(3)

随笔分类(13)

文章分类(131)

文章档案(124)

c++

java

linux

oracle

常用软件

其他

网络配置

系统安全

音乐

搜索

最新评论

阅读排行榜