Bookmark Topic Watch Topic
  • New Topic

How to make a sql queries file and call it from a servlet  RSS feed

 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

My question is is it possible to make a file only for sql queries which can be called from a servlet that uses a specific query?

queries file:
deleteQuery = "dlete from user where username = ?"
insertQuery = "insert into user values (?,?,?,?)"
...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
What you are doing is a good idea Azz Romaysa. Trying to avoid proliferating SQL in code throughout you servlets is the right way to go. One way people often do this is using the DAO pattern. I'd google for it and see if it solves your worries. If you want to keep SQL in one file, look at the java.io package for guidance. And I'd forget your ResourceBundle idea - since they are specifically for internationalization.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am considering this a duplicate post form your other thread asking about queries.properties file, So I am closing this thread.

Thanks

Mark
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!