Working with large XML files in Postgresql
<p>I am using Java JDBC to insert a rather large XML file (about 32MB) into an "xml" type column in Postgres using this particular approach / method: </p>

<pre><code>public void setDataXML(PreparedStatement ps, Connection conn, int index, byte[] bytes) throws SQLException {
    SQLXML sqlxml = conn.createSQLXML();
    OutputStream os = sqlxml.setBinaryStream();
    try {
        os.write(bytes);
    } catch (IOException e) {
        throw new SQLException(e);
    }
    ps.setSQLXML(index, sqlxml);
}
</code></pre>

<p>I am currently using the postgresql-9.4.1208.jar JDBC driver for this operation. Previously this was working just fine when running against a Postgres 9.0.4 database. I have since upgraded to a Postgres 9.4 database, and now this operation is failing with a:</p>

<pre><code>    PreparedStatementCallback; SQL []; ERROR: invalid XML content
Detail: line 418061: internal error: Huge input lookup
nested exception is org.postgresql.util.PSQLException: ERROR: invalid XML content
</code></pre>

<p>I have tested this on Windows as well as an Amazon Linux instance, and the results are the same. I know it has something to do with the size of the XML file, as severely reducing the sheer size of the XML file allows it to be inserted as desired.</p>

<p>What settings can I use on the driver / database, or how to configure as such to allow me to insert a large XML file with Postgres 9.4?</p>