CSDN博客

img javaindex

callablestatement存储过程

发表于2008/9/28 7:29:00  171人阅读

分类: 数据库

 import java.sql.*;
public class TestProc {

 /**
  * @param args
  */
 public static void main(String[] args) throws Exception {
  
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.1:1521:SXT", "scott", "tiger");
  CallableStatement cstmt = conn.prepareCall("{call p(?, ?, ?, ?)}");
  cstmt.registerOutParameter(3, Types.INTEGER);
  cstmt.registerOutParameter(4, Types.INTEGER);
  cstmt.setInt(1, 3);
  cstmt.setInt(2, 4);
  cstmt.setInt(4, 5);
  cstmt.execute();
  System.out.println(cstmt.getInt(3));
  System.out.println(cstmt.getInt(4));
  cstmt.close();
  conn.close();
 }

}

0 0

相关博文

我的热门文章

img
取 消
img