public class RadarL0TypeHandler implementsTypeHandler {
private static final Log LOG =LogFactory.getLog(RadarL0TypeHandler.class);
public RadarL0TypeHandler() {
super();
}
public void setParameter(PreparedStatement ps, int i, Object parameter,
JdbcType jdbcType) throws SQLException {
List objects = (List) parameter;
com.haier.openplatform.jdbc.HOPConnection hopConnection =(com.haier.openplatform.jdbc.HOPConnection)ps.getConnection();
Connection tmpConnection = hopConnection.unwrap(Connection.class);
StructDescriptor structDescriptor =StructDescriptor.createDescriptor("B2C_DATA", tmpConnection);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss");
STRUCT[] structs = new STRUCT[objects.size()];
for (int index = 0; index < objects.size(); index++)
{
RRSLesJDMSG pack = objects.get(index);
Object[] params = new Object[25];
params[0] = pack.getBstnk();
params[1] = pack.getBstkd();
params[2] = pack.getTknum();
params[3] = pack.getPosnr();
params[4] = pack.getSource();
params[5] = pack.getSource_sn();
params[6] = pack.getSdabw();
params[7] = pack.getKunnr();
params[8] = pack.getKunwe();
params[9] = pack.getName1();
params[10] = pack.getMessage();
params[11] = pack.getQ0_lei();
params[12] = sdf.format(pack.getDatetime());
params[13] = pack.getAdd1();
params[14] = pack.getAdd2();
params[15] = pack.getAdd3();
params[16] = pack.getAdd4();
params[17] = pack.getAdd5();
params[18] = pack.getAdd6();
params[19] = pack.getAdd7();
params[20] = pack.getAdd8();
params[21] = pack.getAdd9();
params[22] = pack.getAdd10();
params[23] = sdf.format(pack.getCreate_date_time());
params[24] = sdf.format(pack.getLes_create_date_time());
STRUCT struct = new STRUCT(structDescriptor, tmpConnection, params);
structs[index] = struct;
}
ArrayDescriptor desc =ArrayDescriptor.createDescriptor("TABLE_OF_B2C_INTERFACE",tmpConnection);
oracle.sql.ARRAY oracleArray = new oracle.sql.ARRAY(desc, tmpConnection,structs);
ps.setArray(i, oracleArray);
}
public Object getResult(ResultSet rs, String columnName) throwsSQLException {
Array array = rs.getArray(columnName);
return array.getArray();
}
@Override
public Object getResult(CallableStatement cs, int columnIndex)
throws SQLException {
Array array = cs.getArray(columnIndex);
return array.getArray();
}
@Override
public Object getResult(ResultSet rs, int columnIndex) throwsSQLException {
// TODO Auto-generated method stub
return null;
}
}