Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC

 
Mishra Dinesh Jee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me is there any short cut to use the same callable statement a number of times.
 
Michael Fitzmaurice
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
When you say 'use' the same CallableStatement a number of times, what do you mean? If you want to execute the same stored proc, there shouldn't be a problem with that (in theory at least - I have never actually tried it), even if you are resetting input parameters between calls. To test this, find the part of your code that makes the execute() call, and duplicate it on the next line. If there are problems, you'll soon find out.
A word of warning though. A callable statement and its resultset are linked - this can cause memory leaks in some situations if you are not careful, although in my experience this happens when you are reassigning the same resultset rather than calling the execute method repeatedly on a callable statement.
If you have problems with that, post again and I'll tell you how I got around it.
Hope this helps
Michael
------------------
"One good thing about music - when it hits, you feel no pain"
Bob Marley
 
Stanley Tan
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mishra Dinesh Jee:
Please tell me is there any short cut to use the same callable statement a number of times.

It's a bit unclear what you want to do. But from what I can get from what you have said, you might want to look into PreparedStatements. It's like a statement, but you can use it several times with different parameters.
Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic