Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Putting SQL statements in MVC application

 
Vin Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm creating a simple Java App. which involves MySQL database interaction.

What would the best place to put my SQL statements or access database?

Create JavaBeans? Can I embed it in JSP?(Is it possible!!!)

Thanks,

Vin
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vin,
While it's possible to put the SQL in JSPs, it is very strongly recommended against. It is best to put the SQL in a Java class that is called from the servlet. The servlet stores data in the request and forwards to the JSP.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Putting SQL statements in MVC application


Vin,

When you say MVC, what do you understand by MVC ?

MVC is a Model-View-Cotroller architecturev and a sql can never be part of any view.
JSP is part of the view and actually you should plcace sql some where in model or bean

Now you are better one who can decide

in short don't put sql in jsp what Jeanne said
[ April 06, 2005: Message edited by: Shailesh Chandra ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic