Reputation: 653
I have a requirement that involves me to call aroung 30 -40 separate functions housing sql queries and update and/or insert. In this case how can i get the connection object. Am i suppose to create at one place and pass the connection object to all the 30 functions or do i create the connection object in the function itself. There are many updates happening in these queries in separate functions and time is of the essence. So how do i create the connection object and use the same connection object over and over again without creating a new one.
Upvotes: 1
Views: 604
Reputation: 881
You can save yourself a lot of plumbing (and pain) by using the database connection pooling library offered by Apache Commons: http://commons.apache.org/dbcp/
PS: you appear to have asked this question in the past - see Setting up a jdbc connection pool for sybase - did you follow the advice given there?
Upvotes: 1
Reputation: 28812
Specify an additional parameter of type Connection
in the functions and pass the existing connection to the functions when you are calling them.
Upvotes: 1