Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Connection Pooling, anyone help me please!

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys...
I'm having a bit of headache trying to figure out what's going on with my Connection Pooling since it's not working as it supposed to... it's been opening up to 150 connections for some reason which I don't know why... I've made it as simples as possible but the problem still remains.

Could anyone give me a hand on this one, Please?

 
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I notice that your setupDataSource method creates a new ConnectionPool every time it's called. Correct me if I misunderstand the design, but shouldn't there just be one ConnectionPool which is accessed repeatedly?
 
Gustavo Santos
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:I notice that your setupDataSource method creates a new ConnectionPool every time it's called. Correct me if I misunderstand the design, but shouldn't there just be one ConnectionPool which is accessed repeatedly?


Exactly! so where do you think I should place it in a way that it opens only one ConnectionPool to be accessed repeatedly?

Thanks a lot for your help!

PS: I got this source from the Apache website and I thought it was right... I haven't made any changes in the code itself besides the selects and inserts.
 
Paul Clapham
Marshal
Posts: 25594
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if you have data that has to last longer than a method call, the usual simple way to deal with that in Java is to have class-level variables for the data. That's not specific to JDBC, though, that's just basic Java programming.
 
Message for you sir! I think it is a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic