aspose file tools*
The moose likes Servlets and the fly likes sql query in web.xml or property file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "sql query in web.xml or property file" Watch "sql query in web.xml or property file" New topic
Author

sql query in web.xml or property file

Ankur Bohra
Greenhorn

Joined: Jun 29, 2007
Posts: 19
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


Sun Certified Java Programmer<br />Sun Certified Web Component Developer <br />National Stock Exchange Certification in Financial Market
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39575
    
  27
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).


Ping & DNS - updated with new look and Ping home screen widget
Ankur Bohra
Greenhorn

Joined: Jun 29, 2007
Posts: 19
But how can i write a insert query in property, where each time my parameters changes
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

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

Joined: Dec 11, 2004
Posts: 13410

If you use prepared statements you can list your parameters as '?' symbols.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60072
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Radhakrishna Bhat
Greenhorn

Joined: Dec 26, 2007
Posts: 10
Here is what i do in my applications.

use context-param to store connection strings.

use properties file for Queries.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sql query in web.xml or property file
 
Similar Threads
Properties File For Oracle
Why each hibernate3 query is making full tables scans?
could not read column value from result set: IS6_32_0_; Invalid column name
HIbernate Criteria when fired on VIEW returs list with NULL values
Direcotry Listing