This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes Simplest way to execute a DB query in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Simplest way to execute a DB query in a JSP" Watch "Simplest way to execute a DB query in a JSP" New topic
Author

Simplest way to execute a DB query in a JSP

Renato Losio
Ranch Hand

Joined: Nov 23, 2005
Posts: 99
Hi guys,

what's the simplest way to retrieve a count(*) from a DB table in a brand new jsp page?

I need just a very temp page for a few days and I don't really plan to change the DAO design or integrate the new page in the web app. So simply a 'plug & play' page using the Postgres connection JBoss has or even opening a new connection.

I would then take care of the security of the page in the web.xml

Suggestions? Pitfalls?

Cheers,

Renato


Renato Losio - www.arsenio.it - renatoweb@arsenio.it
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
JSTL SQL Tag is your best bet.
Renato Losio
Ranch Hand

Joined: Nov 23, 2005
Posts: 99
Thanks, done. Now, what's the best bet if I like to move the db connection string to a properties file? Using init-param in the web.xml? Something else I can keep separated of the current web app config files?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Simplest way to execute a DB query in a JSP
 
It's not a secret anymore!