This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I must be looking over it, but is there any way to check the status of the connection LightSpeed has with the database? Thanks in advance! Jeroen Corsius |
|
|
This isn't available directly, because LightSpeed also supports connectionless persistence engines such as SimpleDB. However you can obtain it by implementing a custom connection strategy, and exposing the connection state on your custom strategy. See http://www.mindscapehq.com/documentation/lightspeed/Building-Applications-with-LightSpeed/Customising-How-LightSpeed-Connects-to-the-Database for more info about connection strategies. |
|
|
Thanks for the quick reaction. I implemented it like this:
There was no need to implement the whole Strategy as I was only interested in the connection-state. |
|
|
I don't think that's doing what you want. Unless you implement the full strategy and set an instance of it on the UnitOfWork, all you're doing is splashing in the connection pool without LightSpeed knowing anything about it. In practice, that method basically returns true unless the DB is down, no? |
|
|
I think you're right. I was opening a new connection to the database, just to see if it was working or not. After that the connection got disposed. I've made some changes so the Database uses the ConnectionStrategy. Now I can still test the connection, but the connection is saved if successful. Now it looks like this:
Thanks for the tip! |
|
|
I think that'll work until you run out of connections. :) See CloseConnection and Dispose here: |
|
|
Closing the connection manually was not something I wanted to implement. I assumed this was done automaticly. I added the following code to the CustomConnectionStrategy:
Thanks again! |
|
|
Just to explain the reasoning for this: We automatically call Dispose on the connection strategy. We don't automatically dispose the connection, because a custom connection strategy could recycle connections, or could dispose connections eagerly (with a view to recreating them if required). So it is required for a custom connection strategy to dispose connections according to its intended lifecycle. Which I realise is a pain for you because you don't want to take over the connection lifecycle, you just want a bit more visibility of the connection! With the latest change, what you've got should be fine -- and if you run into any oddities we'd be happy to share our own internal default connection strategy with you. |
|
|
Thanks for the extra information. At the moment everything is working as I need it to. I checked the number of open connections to the database while running/using the application and everything seems to work just fine. |
|