I used this approach. It worked well.
[http://www.cisco.com/web/europe/images/email/signature/est2014/logo_06.png?ct=1398192119726]

Grant Overby
Software Engineer
Cisco.com<http://www.cisco.com/>
[email protected]<mailto:[email protected]>
Mobile: 865 724 4910






[http://www.cisco.com/assets/swa/img/thinkbeforeyouprint.gif] Think before you 
print.

This email may contain confidential and privileged material for the sole use of 
the intended recipient. Any review, use, distribution or disclosure by others 
is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete 
all copies of this message.

Please click 
here<http://www.cisco.com/web/about/doing_business/legal/cri/index.html> for 
Company Registration Information.





From: Dima Dragan <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Friday, April 3, 2015 at 4:57 PM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: JDBC connection pool shared by bolts


Hi,

You can create static class with thread-safe singleton initialization of 
connection pool and provide public access for reference.
Take pool reference in prepare method.
Take connection,execute smth, give it back in execute method.

So every worker will get it's own pool.

Best regards,
Dmytro Dragan

On Apr 3, 2015 11:47 PM, "Nathan Leung" 
<[email protected]<mailto:[email protected]>> wrote:
Do it in prepare.  The topology created in main() is serialized and sent via 
thrift to the nimbus.  It is not possible to serialize and deserialized things 
like a database connection.  The config map is one way you can pass pool 
configuration information though.

On Fri, Apr 3, 2015 at 4:37 PM, Adam Mitchell 
<[email protected]<mailto:[email protected]>> wrote:
Where is the best place to create a JDBC connection pool, and register it so 
that all of my bolts can access it?  To borrow from the examples, would you do 
that near WordCountTopology::main() and save the pool reference in the Config 
map?  That way IBolt::prepare() can use the map...

Or the TopologyContext is also available in IBolt::prepare().  Would you put it 
there somehow?

If you're doing database dips in your bolts, how are you managing your database 
connections?

Reply via email to