Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Stored Procs Vs Direct SQL  RSS feed

 
Gaurav Jain
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it a better approach to write all the stored procedures for DB operations and calling them from java classes or write direct SQL in java classes using a DAO pattren?
 
Arul Prasad
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

It is according to the requirement ..

Mainly we can Go for Stored Procedure when some data is Going to affect more than one table or some business logic should applied

for ex

if one customer transfer the amount of Rs10,000 to the another A/c
here u need to update more than one table and we need to maintain the
transaction..

so if we have some stored procedure we can arrive it in a single DB call.

bye
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on your skillset and requirements. Stored procedures can give you better speed if you have complex business logic that you don't mind putting into an SP. SQL tends to give you better portability.

Either way, tuck whatever you choose behind a DAO interface so that if you change your mind, you only have to change the DAO implementation and not the client code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!