Acerca de CallableStatement
Publicado por Jorge (1 intervención) el 03/01/2007 17:46:13
Hola,
estoy intentado recibir de PL/SQL un RECORD y recogerlo desde una calse java. No sé muy bien como funciona, asi que si algui en me puede ayudar le estaría muy agradecido.
El código que he elavorado es el siguiente:
public CargarBienesBean recuperarParcelaArranque(Connection con)
throws DAOException{
CargarBienesBean devuelto = new CargarBienesBean();
CallableStatement cs = null;
try {
cs = con.prepareCall("begin ? := SIVA_PACK_CARGA_BI.RECUPERAR_PARCELA_ARRANQUE(); end;");
cs.registerOutParameter(1, Types.STRUCT,"SIVA_PACK_CARGA_BI.R_PARCELA_TRATADA");
cs.execute();
Struct struct = (Struct)cs.getObject(1);
devuelto.setAnno((String)struct.getAttributes()[0]);
devuelto.setMunicipio((String)struct.getAttributes()[1]);
devuelto.setParcela((String)struct.getAttributes()[2]);
devuelto.setEstadoCarga(1);
}catch (SQLException ex) {
throw new DAOException(ex.getMessage());
} finally {
if (cs != null) {
try {
cs.close();
} catch (SQLException ex2) {
throw new DAOException(ex2.getMessage());
}
}
}
return devuelto;
}
Un saludo y muchas gracias
Jorge
estoy intentado recibir de PL/SQL un RECORD y recogerlo desde una calse java. No sé muy bien como funciona, asi que si algui en me puede ayudar le estaría muy agradecido.
El código que he elavorado es el siguiente:
public CargarBienesBean recuperarParcelaArranque(Connection con)
throws DAOException{
CargarBienesBean devuelto = new CargarBienesBean();
CallableStatement cs = null;
try {
cs = con.prepareCall("begin ? := SIVA_PACK_CARGA_BI.RECUPERAR_PARCELA_ARRANQUE(); end;");
cs.registerOutParameter(1, Types.STRUCT,"SIVA_PACK_CARGA_BI.R_PARCELA_TRATADA");
cs.execute();
Struct struct = (Struct)cs.getObject(1);
devuelto.setAnno((String)struct.getAttributes()[0]);
devuelto.setMunicipio((String)struct.getAttributes()[1]);
devuelto.setParcela((String)struct.getAttributes()[2]);
devuelto.setEstadoCarga(1);
}catch (SQLException ex) {
throw new DAOException(ex.getMessage());
} finally {
if (cs != null) {
try {
cs.close();
} catch (SQLException ex2) {
throw new DAOException(ex2.getMessage());
}
}
}
return devuelto;
}
Un saludo y muchas gracias
Jorge
Valora esta pregunta


0