Results 1 to 11 of 11
  1. #1
    raj reddy is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default how to Parse int to a string variable

    Hi


    while(rs.next()) {

    String Fname = Integer.parseInt(rs.getInt("tktkey"));


    }


    am getting this type of error


    cannot find symbol

    symbol:methodparseInt(Int)

  2. #2
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Hello Raj,

    Try this

    String Fname = String.valueOf(rs.getInt("tktkey"));

    Or

    String Fname = rs.getInt("tktkey")+"";



    sanjeev

  3. #3
    raj reddy is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    Hi sanjeev

    This is working fine.

    Thks a lot for repling to my queries.


    regards
    Raja

  4. #4
    raj reddy is offline Member
    Join Date
    Apr 2008
    Posts
    31
    Rep Power
    0

    Default

    Quote Originally Posted by sanjeevtarar View Post
    Hello Raj,

    Try this

    String Fname = String.valueOf(rs.getInt("tktkey"));

    Or

    String Fname = rs.getInt("tktkey")+"";



    sanjeev
    Hi sanjeev

    can u pls help in this application




    Hi

    There were two arraylists


    List al1 = (List) classabc.fetchTicketpanel();
    System.out.println("THE LATEST VALUES OF THE TICKET KEY1 IS " + al1 );

    List al2 = (List) classabc.fetchDrawresults();
    System.out.println("THE LATEST VALUES OF THE TICKET KEY2 IS " + al2 );


    Think it as a1,a2,a3,a4,a5 are the elements of al1 and b1,b2,b3,b4,b5,b6,b7,b8,b9,b10.........n number of elements

    of al2.


    how to compare the elements of these two arraylists.

    please i need the code of comparing these two array lists.

  5. #5
    satyadas is offline Member
    Join Date
    Jun 2008
    Posts
    4
    Rep Power
    0

    Default

    String Fname = String.valueOf(rs.getInt("tktkey"));

  6. #6
    kicksfanscom is offline Member
    Join Date
    Jun 2008
    Posts
    15
    Rep Power
    0

    Cool Thank for making this valuable information available to the public..txt

    Thank for making this valuable information available to the public.

  7. #7
    chaitu is offline Member
    Join Date
    Oct 2008
    Posts
    4
    Rep Power
    0

    Thumbs up

    Quote Originally Posted by raj reddy View Post
    Hi


    while(rs.next()) {

    String Fname = Integer.parseInt(rs.getInt("tktkey"));


    }


    am getting this type of error


    cannot find symbol

    symbol:methodparseInt(Int)
    Hi raj reddy,
    Actually the Integer.parseInt(String);
    but what r u passing is integer.
    The better way to get the values is Write a POJO class
    then u create a pojo class object and set the values for pojo class and finally add to arrraylist or vector.
    ex
    while(rs.next())
    {
    //creating Pojo class object
    Test tobj = new Test();
    tobj.setFno(rs.getInt(1));
    tobj.setFname(rs.getString(2));
    // add to ArrayList
    al.add(tobj);
    }
    Ok ,
    While displaying retrieve the arraylist by Iterator u can display the values.

  8. #8
    wolve634's Avatar
    wolve634 is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default

    you can call getString("intColumnName") even if the data you want to retreive is of int type!

    String Fname = rs.getString("tktkey");
    :eek:

  9. #9
    girigl is offline Member
    Join Date
    Dec 2008
    Posts
    4
    Rep Power
    0

    Default how to Parse int to a string variable

    Its very simple You can just call toString(). toString() converts all invoking objects to Stringtype.
    String Fname = (rs.getInt("tktkey")).toString();
    Last edited by girigl; 01-08-2009 at 03:40 PM.

  10. #10
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    I much prefer the example given by @wolve634

    much cleaner. No silly extra calls or conversions

    Use the API, Luke

  11. #11
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    The proper syntax is

    Integer.toString(rs.getInt("key"))

    Integer.parseInt(i) turns an int into a String.

Similar Threads

  1. Replies: 4
    Last Post: 02-22-2009, 05:31 PM
  2. how to Parse int to a string variable (pls hlp)
    By raj reddy in forum Threads and Synchronization
    Replies: 5
    Last Post: 06-10-2008, 07:32 AM
  3. How to parse String effectively based on a dilimiter
    By raghu408 in forum Advanced Java
    Replies: 26
    Last Post: 04-10-2008, 11:55 PM
  4. Replies: 1
    Last Post: 08-03-2007, 11:52 AM
  5. String Variable
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-06-2007, 05:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •