This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Retrieve values from radio buttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieve values from radio buttons" Watch "Retrieve values from radio buttons" New topic
Author

Retrieve values from radio buttons

phani kon
Ranch Hand

Joined: Apr 06, 2005
Posts: 251
I have a jsp with radio buttons for Category below

1.ALL 2.GGG 3. HHH 4.TTT 5.TOT 6.ANYCAT

ANYCAT means select all catgory ie ALL,GGG,HHH,TTT,TOT. In the database, I have a table ALLSTATS table in the database which has got category as one of the column.

Category column contains ALL,GGG,HHH,TTT and TOT contains both( ALL ,GGG).

In the java file I am calling the method which passes the categories like below

ResultSet rs = wds.getData(String Category, int Month, intYear)


StringBuffer query = new StringBuffer("SELECT SUM(AMT), SUM(ADD_COLL) ");
query.append(" FROM "Constants.ALLSTATS" WHERE CAT
='").append(Category). append("' AND YEAR(DATE)=").append(year);

The above query is working fine for all categories(ALL,GGG,HHH,TTT) except TOT. How do I pass TOT catgory also which contains both(ALL, CGG). My code is below


if (Category == TOT)
{

Category =" ALL", +"," +"CGG";

StringBuffer query = new StringBuffer("SELECT SUM(AMT), SUM(ADD_COLL) ");
query.append(" FROM "Constants.ALLSTATS" WHERE CAT
IN'").append("(").append(Category).append(")"). append("' AND YEAR(DATE)=").append(year);


}
[ March 31, 2008: Message edited by: lakshmi manepally ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieve values from radio buttons
 
Similar Threads
cewolf charts
java query
How to write such an EJB-QL
pass array to query
assign multiple values to string