Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / July 2006

Tip: Looking for answers? Try searching our database.

prepareCall creating database connections

Thread view: 
junk@andy-coleman.co.uk - 10 Jul 2006 13:57 GMT
Hi,

I am calling a stored procedure on MS SQL Server using the MS JDBC
drivers with code like this

CallableStatement cs = dbConnection.prepareCall("{call sp_myproc(?)}");
cs.setString(1, value);
cs.execute();

I noticed that my process was establishing a lot of connections to the
database and after some investigation realised that each call to
prepareCall() was creating it's own database connection. I added a call
to cs.close() at the end of the method which solved the imediate
problem.

My concern now is that every time I call prepareCall it is establishing
it's own database connection which must be slowing my process down. Is
there a way of just using the existing connection for the call?

Thanks
Andy
AndyColeman - 10 Jul 2006 14:16 GMT
Appologies but as is typical I post a query and find the solution
straight after.

It seems I was calling prepareCall during the initialisation stage of
my app and not calling close on the CallableStatement. I suspect the
driver thought the connection was still being used and was then
creating an additional connection each time a new call to prepareCall
was made.

Thanks
Andy


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.