标签:resultset ble ase etc web 数组 数组参数 参数 one
注:本文来源于 《 java 实现往oracle存储过程中传递array数组类型的参数 》1 ----------------------------------------------------------------------------------- 2 import java.sql.Connection; 3 import java.sql.PreparedStatement; 4 import java.sql.CallableStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.sql.Types; 8 import java.util.ArrayList; 9 import oracle.sql.ARRAY; 10 import oracle.sql.ArrayDescriptor; 11 import org.apache.tomcat.dbcp.dbcp.DelegatingConnection; 12 public class BussinessLog { 13 public static ArrayList<Comparable> CancelLog(String sLoginUser, Object[] arrLogID) 14 { 15 ArrayList<Comparable> arrList = new ArrayList<Comparable>(); 16 Connection conn = null; 17 CallableStatement callStmt = null; 18 String sql = null; 19 ArrayDescriptor arrDesc = null; 20 21 try 22 { 23 conn = DbConnectionManager.getConnection(); 24 sql = "{call P_CanceltLog(?,?,?,?)}"; 25 callStmt = conn.prepareCall(sql); 26 arrDesc = ArrayDescriptor.createDescriptor("NUMBERTABLE", getNativeConnection(conn)); 27 ARRAY arr = new ARRAY(arrDesc, getNativeConnection(conn), arrLogID); 28 callStmt.setString(1, sLoginUser); 29 callStmt.setObject(2, arr, Types.ARRAY); 30 callStmt.registerOutParameter(3, Types.VARCHAR); 31 callStmt.registerOutParameter(4, Types.INTEGER); 32 callStmt.execute(); 33 34 arrList.add(callStmt.getInt(4)); 35 arrList.add(callStmt.getString(3)); 36 return arrList; 37 } catch (Exception e) { 38 System.out.println(e.toString()); 39 } finally { 40 DbAction.clear(conn, callStmt); 41 } 42 return arrList; 43 } 44 45 public static Connection getNativeConnection(Connection con) throws SQLException { 46 if (con instanceof DelegatingConnection) { 47 Connection nativeCon = ((DelegatingConnection) con).getInnermostDelegate(); 48 return (nativeCon != null ? nativeCon : con.getMetaData().getConnection()); 49 } 50 return con; 51 } 52 }
java 实现往oracle存储过程中传递array数组类型的参数
标签:resultset ble ase etc web 数组 数组参数 参数 one
原文地址:https://www.cnblogs.com/ios9/p/8858210.html