Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading from a XML file or from Database ?  RSS feed

 
Tuna Töre
Ranch Hand
Posts: 220
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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 Java Spring
  • Mark post as helpful
  • send pies
  • 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
 
Rudy Gireyev
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!