This content has been marked as final. Show 3 replies
first of all, I don't see a disconnect in your code. This means that all connections you are establish are never closed normally, and will stay open until they expire and time out. This is bad coding style.
Second, why don't you implement your own connection pool? As more important if your application is multi-threaded. If you don't do that in your scenario, you will quickly hit the Maximum_Sessions_Per_User limit, because most of your sessions will be unused until they time out. This implies even more problems with memory management and garbage collection.
The are tons of examples and tutorials available on the Internet, how to implement a simple connection pool. A connection pool can also intelligently manage the size of the pool and make sure each connection remains valid.
Hope that helps,
Thanks for response. I have a disconnect method in my code ;). Above was just an example . I have implemented connection pool as you adviced it works much faster when pool is already created but Firrst creation of session takes a lot of time I thought that tere is some bulit in machansm that works more quickly than calling ManagersFactory.login(credential, CDBUrl). Pooling solves my problems for now :) thanks.
what exactly is "a lot of time" for you in this context? Is this around 3 seconds? Depending on your hardware and configuration, this could be normal. You could pre-create the sessions during startup of your application to avoid waiting time when the session is requested. This can be done in the background and would have no delay impact on your code.