• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql query in web.xml or property file

 
Ankur Bohra
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

anyone who can help me with some code example of writing a sql query in web.xml or property file.
as i am developing a application with a variable sql query which may change any time.

Select query
Update query
Insert Query
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would put it into a properties file. That way you can write code to reload the file contents at runtime when a particular URL is hit. That's not possible if you put it into web.xml (for which you'd need to reload the whole web application).
 
Ankur Bohra
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how can i write a insert query in property, where each time my parameters changes
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how can i write a insert query in property, where each time my parameters changes


How a property file would differ from web.xml if you are hard coding your SQL into them?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use prepared statements you can list your parameters as '?' symbols.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Todd:


How a property file would differ from web.xml if you are hard coding your SQL into them?

Because property files can be reloaded at any time.
 
Radhakrishna Bhat
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what i do in my applications.

use context-param to store connection strings.

use properties file for Queries.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic