Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 (?,?,?,?)"
...
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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