hello friends,
i get an highlighted error, while retriving column value for column "FirstName" . But 
instead i write the following query by by using every columns name in SELECT clause it 
works..but i am using SELECT *
 
can anyone tell me the root cause of exception
 
the code is like this...
 
package com.struts.friends;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Collection;
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class FriendAction extends Action {

 /**
  * Method execute
  * @param ActionMapping mapping
  * @param ActionForm form
  * @param HttpServletRequest request
  * @param HttpServletResponse response
  * @return ActionForward
  * @throws Exception
  */
 public ActionForward execute(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response)
  throws Exception {
   System.out.println("I'm in FriendAction");
   FriendForm friendForm = (FriendForm) form;
   ActionErrors errors=new ActionErrors();
   try {
   Connection con=null;
   con = LoginAction.getConnect();
   ResultSet rs1 = null;
   Statement stmt = con.createStatement();
   Collection friends = new Vector();
   System.out.println("*********"+request.getAttribute("personId"));
    int personid = Integer.parseInt(request.getAttribute("personId").toString());
    System.out.println("++++++++++++++++personid:"+personid);
    String query = "select * from Friends where friendid in"+
      "(select friendid from personfriends,person where"+
      " personfriends.personid="+personid+")";
    System.out.println("Query2:"+query);
    rs1 = stmt.executeQuery(query);
    while(rs1.next()){
     Friend friend = new Friend();
     friend.setFriendId(rs1.getInt("FriendID"));
     System.out.println("FriendID:"+friend.getFriendId());
     friend.setAddress(rs1.getString("Address"));
     System.out.println("Address:"+friend.getAddress());
     friend.setBirthDate(rs1.getDate("BirthDate"));
     System.out.println("Bdate:"+friend.getBirthDate());
     friend.setCompany(rs1.getString("Company"));
     System.out.println("Company:"+friend.getCompany());
     
     // on next line i get SQLException invalid descriptor index but column name & 
data type match exactly
     
     System.out.println("1stName:"+rs1.getString("FirstName"));
     System.out.println("LastName:"+rs1.getString("LastName"));
     friend.setEmail(rs1.getString("Email"));
     friend.setFirstName(rs1.getString("FirstName"));
     friend.setLastName(rs1.getString("LastName"));
     friend.setMobile(rs1.getInt("Mobile"));
     System.out.println("Mobile:"+friend.getMobile());
     friend.setPhone(rs1.getString("Phone"));
     friends.add(friend);
    }
    //friendForm.setFriends(friends);
    return mapping.findForward("success");
   }catch(Exception e){
    e.printStackTrace();
    errors.add(ActionErrors.GLOBAL_ERROR,new ActionError("errors.noFriends"));
    return mapping.findForward("success");
   }
  }
}


Yahoo! India Matrimony: Find your life partneronline.

[Non-text portions of this message have been removed]






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be made 
it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted. 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17304
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/java_official/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to