Results 1 to 4 of 4
  1. #1
    Armadillo is offline Member
    Join Date
    Jul 2010
    Posts
    15
    Rep Power
    0

    Default Design question: where to put sql

    I am making a webapp that displays stats from a database. I am leveraging the SLQ server to aggregate the data, for example to sum over months.

    This means that i have multiline sql statements in the data access layer of my application. My question is, would it be nicer (better, more easily maintenable) to put the sql statements somewhere in a text file?

    I was thinking maybe use resourcebundles, or something similar. This would have the added bonus of making syntax highlighting possible. (I'm working in Eclipse).

    Where do you put your sql statements?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,386
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Armadillo View Post
    I am making a webapp that displays stats from a database. I am leveraging the SLQ server to aggregate the data, for example to sum over months.

    This means that i have multiline sql statements in the data access layer of my application. My question is, would it be nicer (better, more easily maintenable) to put the sql statements somewhere in a text file?

    I was thinking maybe use resourcebundles, or something similar. This would have the added bonus of making syntax highlighting possible. (I'm working in Eclipse).

    Where do you put your sql statements?
    You can even put those SQL queries in the database itself; it may need a bit of bootstrapping code. You're right: taking those queries out of the Java source code adds a bit of flexibility and 'cleanness' to the Java code. It doesn't really matter where you put them as long as they're immune to malicious hacking.

    kind regards,

    Jos

  3. #3
    Armadillo is offline Member
    Join Date
    Jul 2010
    Posts
    15
    Rep Power
    0

    Default

    Thanks for your reply.
    Calling a stored procedure (or a view, in the case of a select) is a good idea.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Armadillo View Post
    Thanks for your reply.
    Calling a stored procedure (or a view, in the case of a select) is a good idea.
    SPs are more effective than the text, easy to handle parameters and so on.

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 08:49 AM
  2. Design question
    By mac in forum New To Java
    Replies: 2
    Last Post: 05-26-2010, 02:48 PM
  3. question on j2ee design pattern
    By Minu in forum Advanced Java
    Replies: 1
    Last Post: 01-06-2009, 07:50 PM
  4. Design question
    By kfunk in forum New To Java
    Replies: 4
    Last Post: 10-10-2008, 03:33 AM
  5. design question comments wanted - essential class init()
    By Nicholas Jordan in forum Advanced Java
    Replies: 0
    Last Post: 07-22-2008, 09:41 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •