These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: How to control the lifetime of generated stored procedures ?
PostPosted: Tue Jan 13, 2009 5:07 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
Hi,

I'm using Hibernate with MSSqlServer2005 and the jTDS project. When looking at the queries, a lot of sp_prepare statements are generated. In general these queries are re-used for a limited time and then recreated.

Is there a way to control the lifetime - i.e. let SQLServer re-use the sp_prepare statement for a longer period - of these stored procedures ?

Regards, Stefan Lecho.

Hibernate version:
3.2.5.ga

jtds version:
1.2


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 5:15 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
One way is to use a connection pool that caches prepared statements. JBoss AS's pool offers this, as does c3p0. Check the docs for whatever pool you're using.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 5:28 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
We're using C3PO for the Connection Pooling. I suppose that the maxStatements property could be used for this purpose, but I do not completely grasp the exact meaning of it.

Does this parameter specifies the (maximum) number of sp_executes that can be called for 1 sp_prepare statement ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 5:32 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
I can't speak to the implementation of that particular driver but think of how JDBC works. You have a Connection, and you use that Connection to prepare a statement. The PS is tied to the Connection and can be reused over and over again. When you pool Connections, you can quite easily pool/cache the PreparedStatements along with it and keep using them. c3p0 helpfully allows you to configure a max per Connection as well as a global max, if I read the documentation correctly.

You seem to be pretty familiar with what's a happening on the wire so why don't you give it a whirl and let us know what you find?

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.