Thread: SQLException "Connection is closed. Operation is not permitted"

SQLException "Connection is closed. Operation is not permitted"

From
Rajiv Verma
Date:
I'm accessing postgres database through tomcat 4.3.1.
I'm able to execute the select and update query through my application
but Insert query is giving following SQLException :
Connection is closed.  Operation is not permitted.

If I execute the same insert query by simple java program using jdbc
connection, It's working. But the same query is giving above exception
in tamcat.

Please help me. Thanx in advance.

following is the ExceptionStackTrace :

IN insert : insert into account(accNo,traderId,dbcNo,bal) values (1,
'rajiv', 1, 5000.0 )
Insertion Failed : Connection is closed.  Operation is not permitted.
Connection is closed.  Operation is not permitted.
    at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:503)
    at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:320)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:48)
    at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:197)
    at org.postgresql.jdbc1.AbstractJdbc1Statement.executeUpdate(AbstractJdbc1Statement.java:183)
    at src.DataManager.Insert(DataManager.java:64)
    at src.Bank.createAccount(Bank.java:149)
    at src.Trader.getAccount(Trader.java:314)
    at CreateAccount.doPost(CreateAccount.java:144)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:536)

Re: SQLException "Connection is closed. Operation is not

From
Ragnar Hafstað
Date:
On Mon, 2005-04-25 at 03:38 +0530, Rajiv Verma wrote:
> I'm accessing postgres database through tomcat 4.3.1.
> I'm able to execute the select and update query through my application
> but Insert query is giving following SQLException :
> Connection is closed.  Operation is not permitted.

looks like your application is closing the database
connection before the insert.

are you doing the insert within the same tomcat
request as the selects ?

con you reproduce this using the simplest possible
test case. i.e:
have your doPost() only
  a) open db connection
  b) perform select
  c) perform insert
  d) close db connection
  e) return ok page

gnari



Re: SQLException "Connection is closed. Operation is not

From
Clifton Zama
Date:
On Monday 25 April 2005 10:54, you wrote:
> On Mon, 2005-04-25 at 03:38 +0530, Rajiv Verma wrote:
> > I'm accessing postgres database through tomcat 4.3.1.
> > I'm able to execute the select and update query through my application
> > but Insert query is giving following SQLException :
> > Connection is closed.  Operation is not permitted.
>
> looks like your application is closing the database
> connection before the insert.
>
> are you doing the insert within the same tomcat
> request as the selects ?
>
> con you reproduce this using the simplest possible
> test case. i.e:
> have your doPost() only
>   a) open db connection
>   b) perform select
>   c) perform insert
>   d) close db connection
>   e) return ok page
>
> gnari

I am having a similar problem from a stand-alone application.The log says
something about an unexpected EOF , so I thought maybe it was the program
closing the connection.But this is not the case because it closes while
iterating through a result set.It reads the first one , then when rs.next()
is called again , it says : Connection is closed.  Operation is not
permitted.

Clifton