I’m developing an application in which I pick rcode(numbers) from the database with the name. If the name is present it will display the rcode associated with it. The output like
10001
Suppose, if two names are present with the same name, it will display like
10001 10002
Here is my servlet code for this..
ResultSet rs=stmt.executeQuery("select * from newfarmer where rname='"+get+"'");
while(rs.next()){
username=rs.getString("rname");
if(get.equals(username)){
rcode=rs.getString("rcode");
out.println(rcode);
}
}
and,
I’m using the following code in my android application to get the data from it. That is I need to pick all the data something like where rname=” “. Now the problem is if two records with the same name are present, It will pickup only one record. But servlet outputs show as
10001 10002
In my application I count the total number of records and display it. But it shows only one
String line = null;
while ((line = reader.readLine()) != null) {
StringTokenizer st=new StringTokenizer(line);
count=st.countTokens();
Toast.makeText(getBaseContext(), count+" names found",
Toast.LENGTH_SHORT).show();
r_code=st.nextToken();
ff=1;
}
So, I need to access both the records and also count the total no.of records. Can anyone help to do this
out.println(rcode)adds a CRLF (which is ignored when you look at the output with a browser). What happens if you replace it with a space character ?