Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Reading from a XML file or from Database ?

 
Ranch Hand
Posts: 220
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to create a XML file storing a SQL stament which could be changed time to time manually and I would like to read it inside a Web Service application.
By doing that, I do not want to start the Application server and get customized SQL inside my Java Classes on Web Service Application. Only changing the XML file would be fine for me and the application will be more flexible to be change in the future.

However I have some reservations about reading a file inside a Web Application. The main issue is locking or similar Exceptions issue while reading the custom SQL from XML or performance issues.
Which approach do you think to best for me to prevent getting exceptions such as file locking exceptions.. Reading the Custom Query from DB or from a XML file?

Which one do you think the best?
I dont want to get file reading Exceptions such as locking on a file or similar?


Tuna TÖRE
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you read and parse the XML file into a DOM when the service starts, recovering the text from the DOM will be very quick.

I can't see what locking has to do with this.

How often do you expect the XML file to be changed, and by what?

Bill
 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I would like to read the XML file by using SAX parsing method and the XML wont change too much may be once in a month?

My question also applies for reading values from properties file?
What do you think about that?

It seems a good solution for me to read constants from properties file rather than reading them from Database.
With this approach, I can also change the properties file and I dont need to restart the Server to change Java class files.

Tuna TÖRE
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tuna Töre wrote:Actually, I would like to read the XML file by using SAX parsing method and the XML wont change too much may be once in a month?

Generally speaking the file only gets locked when it is being updated.

Tuna Töre wrote:My question also applies for reading values from properties file?
What do you think about that?

It seems a good solution for me to read constants from properties file rather than reading them from Database.
With this approach, I can also change the properties file and I dont need to restart the Server to change Java class files.

Tuna TÖRE

You'll have to clarify what you mean here. At the moment Properties within Java are expected to come from a properties file. I'm not aware of any support for a DB. Unless you read it from the DB yourself and then manually insert it into a Properties object one by one.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic