) {
_struct = new MutableStruct(new Object[_sqlType.length], _sqlType, _factory);
}
public Datum toDatum(Connection conn) throws SQLException {
_struct.setAttribute(0, this.id);
_struct.setAttribute(1, this.name);
_struct.setAttribute(1, this.code);
return _struct.toDatum(conn, _ORACLE_TYPE_NAME);
}
public PocoTestModel(String id,String name, String code) {
this();
this.id = id;
this.name = name;
this.code = code;
}
....
}
Connection con = null;
CallableStatement cstmt = null;
try {
con = OracleConnection.getConn();
System.out.println(new Date());
List
orderList = new ArrayList
(); for(int i=0;i<100000;i++){ orderList.add(new PocoTestModel(UUID.randomUUID().toString(),"name"+i,"code"+i)); } ArrayDescriptor tabDesc = ArrayDescriptor.createDescriptor("poco_test_object_arr_type", con); ARRAY vArray = new ARRAY(tabDesc, con, orderList.toArray()); cstmt = con.prepareCall("{call poco_test_arr_pro(?)}"); cstmt.setArray(1, vArray); cstmt.execute(); con.commit(); }catch ...
上面是所查到的Oracle批量插入的资料,关于C++方面,没有找到像JDBC类似的方法,提供数组类型的参数的存储过程的调用。下篇文章将介绍另外一个方案,来完成Oracle数据的批量插入。
|