wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Question" Watch "JDBC Question" New topic
Author

JDBC Question

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
hi
My Requisition_details table data is like this;i will do sending email and all those things;What i want is lets take user "vijay" has rejected 4 requisitions.how to group him ;i cannot hard code it like if rs.getString("userid") .equals("vijay") then call sendemail method;i dont know which user come will come from table.how to accomplish this.

requistionidstatususerId
1 Rejectedvijay
2 Newshekar
3Rejectedvijay
4InvalidDatashekar
5Rejectedjayavalli
6Rejectedvijay
7Rejectedjayavalli
8Rejectedshekar
9Rejectedvijay
10Rejectedshekar
11Rejectedjayavalli
12New vijay

in java class i have written like this;
Hashtable ht = new Hashtable();

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc dbc:chaitu");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select requistionid,status,userId from Requisition_Details");
while(rs.next()){
if(rs.getString("status").equals("Rejected")){
ht.put(rs.getString("requistionid"),rs.getString("userId"));
}
[ March 02, 2004: Message edited by: Bear Bibeault ]
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Hi Kesava,
I think this may not be a JSP problem, it should be a JDBC problem.
You can simply rewrite your query:
SELECT id, user FROM TABLE WHERE status = 'Rejected' GROUP BY user;
Does this help?
Nick.
[ March 02, 2004: Message edited by: Nicholas Cheung ]

SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Moving to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
Originally posted by Nicholas Cheung:
Hi Kesava,
I think this may not be a JSP problem, it should be a JDBC problem.
You can simply rewrite your query:
SELECT id, user FROM TABLE WHERE status = 'Rejected' GROUP BY user;
Does this help?
Nick.
noooooooooooooo;i cant change the query
[ March 02, 2004: Message edited by: Nicholas Cheung ]
 
 
subject: JDBC Question
 
Similar Threads
error in validateuer.jsp page
how to do this with hashtable
Synchronization problem with session?!
Validating Username and Password in JSP
very urgent