oracle学习笔记17--PLSQL4
package com.morflame;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;public class GetEmpInfo {public static void main(String[] args) {try {Class.forName("oracle.jdbc.driver.OracleDriver");Connection conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");CallableStatement cs=conn.prepareCall("{call getEmpInfoByDeptno(?,?)}");cs.setInt(1, 10);cs.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);//^_^cs.execute();ResultSet rs=(ResultSet)cs.getObject(2);while(rs.next()){System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3));}rs.close();cs.close();conn.close();} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();}}}