Svein Thomas wrote:
Hibernate version:1.2.0.3001
Name and version of the database you are using:SQL Server 2005
Once again I will try to ask this forum about a connection issue between OpenSession and session.close(). And how to reconnect when this happends.
I have a application that are selecting, updating and deleting rows in some database tables.
My trouble is that the Database server is not on the same computer that my application is running on and sometimes I loose connection to this server.
When this happens, I will get an error on some of the object. But since I use the lazy model (i think), the exception does not come right away. I am able to select from my tables (that are selected from before) regardless of the connection state. But I cant update when the connection is down, and that is correct.
I want to know right away when I loose the connection to the database.
How can I do this?
Do anyone have a nice solution for monitoring the connection state to a database server?
Regards
Svein Thomas
I don't believe you are looking at the problem from the right angel since I don't understand why you need to know when a connection is dropped. You won't be able to resume with a new connection in many cases and even if you do you will have to solve transaction problems. You will have to design your code so that database failures are tolerated. I do recommend that you slice up your units of work into smaller pieces and put them in a JMS queue so that they can be retried. You may also consider doing read only parts and write only parts even though in many cases this distinction is impossible.
Farzad-