Oracle 12C + Java + XMLType

3

Hello, Good morning in my company we are testing Oracle 12c. And I found a "problem" to query a field that is the XMLType type. We saved all xml from nfe in the database, so we always have to query this xml. The problem is this, when I query in Oracle 12, the xml comes formatted, and so loses the digital signature of the file. Does anyone have any tips on how to bring this unformatted xml?!? any help is very welcome. Here is my code:

PreparedStatement st = con.prepareStatement("select  nfe_xml from nfe_xml where NFE_CHAVE_ACESSO = ?");

st.setString(1, chaveAcesso);
ResultSet rs = st.executeQuery();
OracleResultSet orset = (OracleResultSet) rs;
while(orset.next())
{ 
    //orset.getOPAQUE(1);
    //XMLType poxml = XMLType.createXML(orset.getOPAQUE("NFE_XML"));
    XMLType poxml = (XMLType)orset.getObject(1); 

    String sXml = ( poxml).getStringVal();
    System.out.println("xml: "+sXml);

    podoc = (Document)poxml.getDOM();
    Util.gravarXmlNfe("C:\NFE\"+chaveAcesso+".xml", podoc);
    String sXml2 =Util.convert(podoc, null) ;
    System.out.println(sXml2);
}
    
asked by anonymous 15.08.2014 / 15:23

1 answer

1

Instead of using the getStringVal method to get the contents of the XML, you can use the getInputStream method that returns a InputStream for you to read the XML byte to the database byte.

Make sure that XML is being written to the database in a column of type LOB , because only then will the original information be preserved. This is explained documentation .

    
14.09.2014 / 04:59