title: java.lang.NegativeArraySizeException while running INSERT query in ojdbc8
body: <p>While trying to run an INSERT query as follows:</p>
  
  <pre><code>javax.persistence.Query query = entityManager.createNativeQuery(MY_NATIVE_QUERY);
  return query.executeUpdate();
  </code></pre>
  
  <p>from my Java application I am getting the below error: </p>
  
  <pre><code>java.lang.NegativeArraySizeException: null
  at oracle.net.ano.CryptoNIONSDataChannel.readDataFromSocketChannel(Unknown Source) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CMAREngineNIO.prepareForReading(T4CMAREngineNIO.java:98) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CMAREngineNIO.unmarshalUB1(T4CMAREngineNIO.java:534) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:485) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:252) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:612) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:226) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:59) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:910) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1119) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3780) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.T4CPreparedStatement.executeInternal(T4CPreparedStatement.java:1343) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.OraclePreparedStatement.executeLargeUpdate(OraclePreparedStatement.java:3865) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3845) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1061) ~[ojdbc8-12.2.0.1.jar:12.2.0.1.0]
  at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
  at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) ~[commons-dbcp-1.4.jar:1.4]
  at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
  at org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:211) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
  at org.hibernate.internal.SessionImpl.executeNativeUpdate(SessionImpl.java:1346) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
  at org.hibernate.internal.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:389) ~[hibernate-core-4.3.10.Final.jar:4.3.10.Final]
  at org.hibernate.jpa.internal.QueryImpl.internalExecuteUpdate(QueryImpl.java:371) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
  at org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:78) ~[hibernate-entitymanager-4.3.10.Final.jar:4.3.10.Final]
  </code></pre>
  
  <p>Database in use is Oracle 10g and jdbc driver in use is ojdbc8-12.2.0.1. The insert query is a simple insert which selects data from a join of 2 tables and inserts in another one. </p>
  
  <p>Moreover, I don't get this exception in development and it only occurs in production. I came across a solution <a href="https://community.oracle.com/thread/733697" rel="nofollow noreferrer">here</a> which says its an internal Oracle driver bug and advises to upgrade to latest 10g driver. But I already have 12c driver. How to resolve this issue? </p>