This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed." Watch "com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed." New topic
Author

com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed.

bhas nik
Greenhorn

Joined: Mar 20, 2013
Posts: 5

Hi,

Please help me on the exception which am getting while
executing stored procedure from my standalone java
application which has pool of connection objects.
Error :JZ006: Caught IOException:
com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0:
Connection is already closed.
java.sql.SQLException: JZ006: Caught IOException:
com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0:
Connection is already closed.
at
com.sybase.jdbc3.jdbc.ErrorMessage.createIOEKilledConnEx(Unknown
Source)
at
com.sybase.jdbc3.jdbc.ErrorMessage.raiseErrorCheckDead(Unknown
Source)


Am using sybase db version ASE 15.0.3/EBF17775
and using driver jar jconn3.jar 6.05/EBF16676(Recently
upgraded)
Since upgrade facing the above exception now and then.

Thanks in advance for your help.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Welcome to the Ranch!

Isn't it possible that this is connected to the other exception you're encountering? If the Connection already closed is always preceded by the Read timed out exception, then perhaps the connection gets closed after that timeout and your exception handling code (perhaps a finally block) closes it again? And perhaps the upgrade caused some change to the timeout interval?

(I personally find it amusing that a call on Connection.close() may fail. I just catch and log any exceptions raised by this call and that's it, I wouldn't know what to do with these exceptions annyway.)
bhas nik
Greenhorn

Joined: Mar 20, 2013
Posts: 5

Hi Martin,

Thank you for your response and for your valuable time.
Into the issue ---it is not related to the other exception which i have encountered and posted.This is completely different exception which i encountered on one day and other on other day.This SybConnectionDeadException am getting it now and then ..... i suspect this could be because of the version upgrades of jconn3.jar , commons-pool-1.5.5.jar and commons-dbcp.jar.Please help.Thanks in advance.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Where in your code does the exception occur? Ie. what DB operation is your code doing at that time?
bhas nik
Greenhorn

Joined: Mar 20, 2013
Posts: 5

At the below said place am getting the exception.

CallableStatement cls = connection.prepareCall("SOME STOREDPROCEDURE");
cls.setString(1,"SOME STRING");
cls.setString(2, "SOME STRING");
cls.setString(3, "SOME STRING");
cls.setString(4, "SOME STRING");
cls.setString(5,"SOME STRING");
cls.setString(6,"SOME STRING");
cls.setString(7,"SOME STRING");

rs = cls.executeQuery();(AT THIS POINT AM GETTING THE EXCEPTION)
Abdulla S Mamuwala
Greenhorn

Joined: Jul 27, 2009
Posts: 21
Your exception indicates that "Connection is already closed.". In that case you should be getting an exception at line:
CallableStatement cls = connection.prepareCall("SOME STOREDPROCEDURE");
Because at this line you are trying to creates a CallableStatement on a closed connection. As per Connection.prepareCall() api,
Throws:
SQLException - if a database access error occurs or this method is called on a closed connection

Sometimes it does happen that you unintentionally close your connection at some point in your code. I would suggest for test purposes to check the status of your connection using isClosed() before you start doing stuff with it. Also check how your connection is handled, particularly at what points you close it. Use search in Eclipse or RAD for this purpose.
bhas nik
Greenhorn

Joined: Mar 20, 2013
Posts: 5

Hi Abdulla,

Thanks for your response.
Into the issue exception is not getting thrown at preparecall ....exception is coming at line executequery().One more thing need to say is connection is no where it is closed once it is created untill it finishes the retrieval from resultset and in finally am closing the connection.If connection is closed in the code before calling executequery() then it will happen everytime i do call this block of code , so it is not happening everytime i do call and this code is running since ages.But here i want mention clearly is after updating the jars (2 to 3 months back updated) which mentioned earlier am facing this type of issue once in month or two.This block of code runs roughly for thousands to lacks of times in a month and almost all the times it is executing perfectly.Here again i can say i do suspect on updated jars versions conflicts.
Alex Oliveira
Greenhorn

Joined: Jun 18, 2014
Posts: 1
Hi, bhas nik!

I´m facing exactly the same problem. I have the same situation:
- migration: jconn2 to jconn3
- This exception (same com.sybase.jdbc3.jdbc.ErrorMessage.createIOEKilledConnEx) on CallableStatement.executeQuery for a procedure call

Did you find some work-around solution for this ?

Database: Sybase ASE 15.2

Thanks in advance.
Kind regards
Alex
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: com.sybase.jdbc3.jdbc.SybConnectionDeadException: JZ0C0: Connection is already closed.
 
Similar Threads
Hibernate : SybSQLException: ASA Error -98: Authentication violation
Datasource.getConnection() hangs when network goes down...
Connection is already closed.due to Firewall
pattern to deal with exception in the commit or rollback phase
Connection is already closed due to Firewall