Support Questions
Find answers, ask questions, and share your expertise

java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Highlighted

java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Explorer

stacktrace:

at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:156) ~[ojdbc6.jar:11.2.0.1.0] at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:126) ~[ojdbc6.jar:11.2.0.1.0] at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:201) ~[ojdbc6.jar:11.2.0.1.0] at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:427) ~[ojdbc6.jar:11.2.0.1.0] at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1251) ~[ojdbc6.jar:11.2.0.1.0] at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494) ~[ojdbc6.jar:11.2.0.1.0]............................

...............................

I am trying to convert my json string to sql script in which i successfully connected to database but I'm getting this error.

What might be the problem?

8 REPLIES 8
Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Can you provide the full stacktrace?

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Explorer

2016-10-19 07:10:06,557 ERROR [Timer-Driven Process Thread-6] o.a.n.p.standard.ConvertJSONToSQL ConvertJSONToSQL[id=6a800168-2e5a-46e2-96a7-f7904689e6a6] Failed to convert StandardFlowFileRecord[uuid=1200130b-cca2-4ba3-ad07-2287e3340754,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1476875036101-1, container=default, section=1], offset=38616, length=150],offset=0,name=Test1.0-38616.txt,size=150] into a SQL statement due to java.sql.SQLException: Stream has already been closed; routing to failure: java.sql.SQLException: Stream has already been closed

2016-10-19 07:10:06,557 ERROR [Timer-Driven Process Thread-6] o.a.n.p.standard.ConvertJSONToSQL

java.sql.SQLException: Stream has already been closed

at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:156) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:126) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:201) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:427) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1251) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494) ~[ojdbc6.jar:11.2.0.1.0]

at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263) ~[na:na]

at org.apache.nifi.processors.standard.ConvertJSONToSQL$ColumnDescription.from(ConvertJSONToSQL.java:677) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processors.standard.ConvertJSONToSQL$TableSchema.from(ConvertJSONToSQL.java:621) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processors.standard.ConvertJSONToSQL.onTrigger(ConvertJSONToSQL.java:267) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) [nifi-api-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1054) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:127) [nifi-framework-core-0.7.0.jar:0.7.0]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_40]

at java.lang.Thread.run(Unknown Source) [na:1.7.0_40]

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Super Guru

Looking at Oracle messages looks like a double get

http://gerardnico.com/wiki/jdbc/oracle

You need full logs to see what's happening.

You don't have two processors trying to do this at once?

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Explorer

No I'm using only one processor.

log:

2016-10-19 07:10:06,557 ERROR [Timer-Driven Process Thread-6] o.a.n.p.standard.ConvertJSONToSQL ConvertJSONToSQL[id=6a800168-2e5a-46e2-96a7-f7904689e6a6] Failed to convert StandardFlowFileRecord[uuid=1200130b-cca2-4ba3-ad07-2287e3340754,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1476875036101-1, container=default, section=1], offset=38616, length=150],offset=0,name=Test1.0-38616.txt,size=150] into a SQL statement due to java.sql.SQLException: Stream has already been closed; routing to failure: java.sql.SQLException: Stream has already been closed

2016-10-19 07:10:06,557 ERROR [Timer-Driven Process Thread-6] o.a.n.p.standard.ConvertJSONToSQL

java.sql.SQLException: Stream has already been closed

at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:156) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.LongAccessor.getBytes(LongAccessor.java:126) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:201) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.T4CLongAccessor.getString(T4CLongAccessor.java:427) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:1251) ~[ojdbc6.jar:11.2.0.1.0]

at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494) ~[ojdbc6.jar:11.2.0.1.0]

at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:263) ~[na:na]

at org.apache.nifi.processors.standard.ConvertJSONToSQL$ColumnDescription.from(ConvertJSONToSQL.java:677) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processors.standard.ConvertJSONToSQL$TableSchema.from(ConvertJSONToSQL.java:621) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processors.standard.ConvertJSONToSQL.onTrigger(ConvertJSONToSQL.java:267) ~[nifi-standard-processors-0.7.0.jar:0.7.0]

at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27) [nifi-api-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1054) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:136) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47) [nifi-framework-core-0.7.0.jar:0.7.0]

at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:127) [nifi-framework-core-0.7.0.jar:0.7.0]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_40]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_40]

at java.lang.Thread.run(Unknown Source) [na:1.7.0_40]

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Explorer

I'm not using LONG Datatype in my table

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

New Contributor
Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

Super Guru

Could be this low level oracle protocol fault showing in JDBC

https://blog.jooq.org/2015/12/30/oracle-long-and-long-raw-causing-stream-has-already-been-closed-exc...

ojdbc6.jar is an old Oracle driver

if you have a new version of Oracle, use the latest oracle jdbc driver

Highlighted

Re: java.sql.SQLException: Stream has already been closed(convert JSONtoSQL)

New Contributor

Sadly, the Stackoverflow solution did not work for me. Does anyone have an alternative?