标签:
package dao;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import model.emp;
import oracle.jdbc.OracleCallableStatement;
import util.DBConn;
public class EmpDao {
Connection conn = null;
Statement statement = null;
ResultSet rs = null;
CallableStatement stmt = null;
public ArrayList<emp> empSel() throws SQLException{
ArrayList<emp> al=new ArrayList<emp>();
conn=DBConn.getConnection();
statement = conn.createStatement();
stmt = conn.prepareCall("call P_GET_PRICE(?)");
stmt.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
stmt.executeUpdate();
//取得结果集
rs = ((OracleCallableStatement) stmt).getCursor(1);
// 对结果进行输出
while (rs.next()) {
emp em=new emp();
em.setEMPNO(rs.getInt(1));
em.setENAME(rs.getString(2));
em.setJOB(rs.getString(3));
em.setMGR(rs.getInt(4));
al.add(em);
}
return al;
}
}
标签:
原文地址:http://www.cnblogs.com/susuhyc/p/5235688.html