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