wood burning stoves 2.0*
The moose likes JDBC and the fly likes java.net.SocketException: Broken pipe 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 "java.net.SocketException: Broken pipe" Watch "java.net.SocketException: Broken pipe" New topic

java.net.SocketException: Broken pipe

Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
I've been trying to integrate pooling in my app. But there are times I get this stack trace when accessing database:

My guess is that the pooling handed me a coneection, and the pooling terminated that connection object. So when I try to call con.close from my app, I got this exception. Do I guess correctly? hat's the solution for this problem? I'm using commons dbcp.
Hendra Kurniawan
Ranch Hand

Joined: Jan 31, 2011
Posts: 239
Everything works just fine in my home PC, but when I put it in remote server, the errors just keep on coming. What could be the problem? Thanks
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

You wrote:
But there are times I get this stack trace when accessing database

I understand then that the error you are getting is intermittent.
In that case, I'm guessing the problem is caused by a timeout that is configured in the connection pool.
From the stack trace you posted, I get the impression that you are keeping the database connection open while the user browses your Web page and sometimes the user browses for such a long time that you hit the connection pool timeout.
If that is the case, I suggest reviewing your code.
Obtain a database connection immediately prior to performing a database operation and release the connection as soon as the operation has completed.
Are you hanging on to the database connection because you think that by doing so you are improving performance?
That is precisely the reason for using a connection pool, so that you don't have to keep the database connection open all the time in your app code.

Good Luck,
I agree. Here's the link: http://aspose.com/file-tools
subject: java.net.SocketException: Broken pipe
Similar Threads
Problem with LazyInitializationException
Problem to run my application
org.springframework.web.HttpSessionRequiredException: Session attribute 'user' required - not found
Hibernate 3: java.sql.SQLException: Field 'passwordConfirmation' doesn't have a default value
wild cards in MySQL using jdbc