File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC queries or stored procedure

 
anish jain
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is a simple select or update statements needs to be fired then which one is better
1) write a simple JDBC query or
2) write a stored procedure for that

I am a bit confused between these two...which one will yield better performance

Also on what basis we should select if we should go for simple JDBC queries(Statement/PreparedStatement) or Strored procedure(CallableStatement)..

 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use stored procs unless there's a need for them. Anything that can be handled in a single SQL statement is not a good candidate for stored procs.
 
anish jain
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Don't use stored procs unless there's a need for them. Anything that can be handled in a single SQL statement is not a good candidate for stored procs.


do you mean to say the performance of calling a single SQL statement will be better than calling a stored procs?
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there are other reasons than performance to prefer one over the other. If there is a performance difference between the two it's likely to be too small to measure.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33699
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anish jain wrote:Also on what basis we should select if we should go for simple JDBC queries(Statement/PreparedStatement) or Strored procedure(CallableStatement)..

QA big downside to a stored procedure is you have to keep it in sync with the version of your code you have deployed. For a simple SQL statement, this downside is not offset by any upside.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic