wood burning stoves 2.0*
The moose likes JDBC and the fly likes Restart of database server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Restart of database server" Watch "Restart of database server" New topic
Author

Restart of database server

Thara Visu
Ranch Hand

Joined: May 17, 2005
Posts: 87
Hi all,

Assume a situation where the database server is restarted. Will a website on the server work without any problem i.e will the app server be able to detect if the database server is up or not or would we have to restart the app server?

Thanks in advance.


Thara<br />SCJP 1.4 96%<br />SCBCD 1.3 96%
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Some servers would pick up the missing database immediately and start producing errors to the servers log file. This is usually the case if you use standard data sources such as in J2EE.

Other servers (or if the database connection is hard-coded via JDBC calls in the application code) would only detect errors if database queries were issued while the database was down. After all, you can't run queries on a server that isn't available.

In all cases though, the application server should be able to detect when the database server is back up and start working again. The only downside is that if you have any cached objects from the database on the application server, they may need to be resynched, ergo a restart of the application server may be required if your persistence manager does not handle this.
[ December 07, 2005: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

Oh and as a side note, application servers restart far more frequently than database servers (which I almost never restart) so its probably a good practice to take the application server down if you are restarting the database. In most situations, there's not much an application server can do while its database is down anyway.
[ December 07, 2005: Message edited by: Scott Selikoff ]
Thara Visu
Ranch Hand

Joined: May 17, 2005
Posts: 87
Thanks.
So what is the whole concept of Stale Connections?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3697
    
    5

That's just the name or type of exception an application is going to receive while the database is unavailable from the Connection object. A new Connection object must be established after some specified retry delay, or a failure must be reported to the user.

Also, if this is a WebSphere server check out:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/rdat_stalconexp.html
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39537
    
  27
What's more, database connections are just fancy network connections, which sometimes are dropped for no discernible reason. So even if the DB is up all the time, the connection can go stale. That's why any decent DB connection pool will close and reopen DB connections every so often.


Ping & DNS - updated with new look and Ping home screen widget
 
 
subject: Restart of database server
 
Similar Threads
Database goes down for sometime?
restarting app server
I am not able to run servlet class
Switching[restarting] Database forces to restart application
ResourceBundle