File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "SQLException" Watch "SQLException" New topic


Claudia Vaz
Ranch Hand

Joined: Nov 13, 2001
Posts: 44
I have a sessionEJB which create and active methods create connections to a database via JDBC. The EJB has a method call getData() that executes a query.
I also have a Web Application that in the first jsp creates an instance of the EJB and saves it into a session variable. In the second jsp, i get the EJB from the session variable and execute the method getData.
The EJB and WebApllication are deployed in Weblogic6.1.
The Database is shutdown every night.
In the case of weblogic6.1 in Windows plataform every thing is ok!. The problem is when the plaform is solaris. The database used is the same for Windowns and Solaris.
Every first time in a day that i try to use the web application, it throws the Exception: java.sql.SQLException: No more data to read from socket. the exception is throwned when i try to execute the method getData.
I stop the server(weblogic), start it and the problem disapears until the next morning!?!?
I am confused!!! Can anyone help me? It�s urgent!!!
Tina Coleman
Ranch Hand

Joined: Dec 12, 2001
Posts: 150
I'm only beginning to play with EJBs, so don't have an understanding of whether the EJB would try to hold onto a JDBC connection (and thus have a problem once the db was shut down overnight) or would create it as needed. Maybe that's the difference between the Solaris and the Windows platform. Regardless. . . as a quick fix, can you either set up a cron job to restart the server after the time that the database is restarted, or put a procedure in your database that would restart the webserver once the database is started?
Rajeev Gupta

Joined: Oct 21, 2002
Posts: 7
Looks like your Connectio Pool (Data Source) connections are going stale as it loses all connections to the database when the database shuts down.
I guess you will have to somehow recreate the connection pool every morning or you can write a Connection Pool, associate it with a Timer, so that it knows when to reduce the size of the pool to zero (at night) and recreate it in the morning.
Another thing worth trying would be to have the initial size of the pool to zero, and have srink to size flag set. Its my guess that when the application is not used, the pool size will reduce to zero (at night), and when the application is up and running (morning), it will recreate all the connections. This way you will not have a stale connection.
Hope this helps...

Rajeev Gupta<br />SCJP,SCJD
I agree. Here's the link:
subject: SQLException
It's not a secret anymore!