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
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply 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: 35220
    
    7
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).


Android appsImageJ pluginsJava web charts
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: 3359

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: 56150
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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
Direcotry Listing
HIbernate Criteria when fired on VIEW returs list with NULL values
Why each hibernate3 query is making full tables scans?
Properties File For Oracle
could not read column value from result set: IS6_32_0_; Invalid column name