I am working on an old legacy Java application and I have some problem with this method that perform a simple insert query on an Oracle database:
private boolean insertFlussoXmlsdi(DBOperatore op, String numeroFattura, String dataFattura, String fatturaXml) {
StringBuffer query = new StringBuffer();
query.append("INSERT INTO FLUSSO_XMLSDI (NUMERO_FATTURA, DATA_EMISSIONE, XML) VALUES (");
query.append(numeroFattura);
query.append(", date'");
query.append(dataFattura);
query.append("', '");
query.append(fatturaXml);
query.append("')");
try {
Statement stmt = op.getConnessione().createStatement();
stmt.execute(query.toString());
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
TraceLog.scrivi("INSERIMENTO FATTURA", "ERRORE inserimento fattura con numero fattura: " + numeroFattura, false, TraceLog.lowConsole + TraceLog.highTrace + TraceLog.highLog);
return false;
}
TraceLog.scrivi("INSERIMENTO FATTURA", "Inserimento fattura con numero fattura: " + numeroFattura, false, TraceLog.lowConsole + TraceLog.highTrace + TraceLog.highLog);
return true;
}
The problem is that the String fatturaXml paramether represent an XML file and it is pretty big. So when the previous query is performed I obtain that this exception is thrown:
java.sql.SQLException: ORA-01704: string literal too long
How can I solve this issue and correctly insert the record?
Tnx
If one tries to insert data which is greater than 4000 characters into a column - VARCHAR2 , they would the error ORA-01704. Check the below SO post
Error : ORA-01704: string literal too long