Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataSource - Flush

 
Juan Marino
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody!!! Well, here comes my question....

I've been working with a DataSource in Glassfish but I'm wondering if is there any way in which I could make a flush from code?...
I mean... Yoou can make the container validate the connection, but that produces overhead.. so it is possible to catch an exception and
make a flush in that moment?

And forgive me for my bad English... :O
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand what you mean by "flush" - what is it you want this to do?
 
Juan Marino
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
flush -> Restart the pool... Restart all the connections
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Disconnecting and reconnecting is the only way to do this. Because you have a connection pool you will not actually know if the connection is actually closed or just returned to the pool.

I can't think of a reason why you would want to do this though. What is driving this requirement?
 
Juan Marino
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I´m working on "electronic funds transfer", and my boss was asking me about it
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does your boss believe you need to close all connections in the pool and reopen? Seems like a fairly odd requirement, its possible she/he is misunderstanding how databases work?
 
Juan Marino
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If in any moment the DataBase is restarted, all the connections in the pool are lost and there is no way in which we can restart those connections but validating it by Glassfish
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Connection pool implementations can usually recover from this. I don't know GlassFish that well, but I'd be surprised if it doesn't have this feature. Worth a look in the docs.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic