Tostring(),getstring()method walin wenne mokakda??

blackcatcyb

Active member
  • Jun 9, 2007
    649
    162
    43
    New Zealand
    toString() method eka apita use karanna puluwan object ekak text ekak widiyata represent karanna
    EX: apita integer value ekak text ekak widiyata pennanna oni nam
    int x=10;
    String a=x.toString();


    getString() method eka use karanne database table eken result set ekata ganna data retrieve karanna

    EX: String a="";
    Resultset rs=stmt.executeQuery("query")
    while(rs.next())
    {
    a=rs.getString(1);
    }

    Retrieves the value of the designated column in the current row of this ResultSet
     

    amila.ela

    Well-known member
  • Mar 24, 2010
    8,645
    626
    113
    මිහිමත
    toString() method eka apita use karanna puluwan object ekak text ekak widiyata represent karanna
    EX: apita integer value ekak text ekak widiyata pennanna oni nam
    int x=10;
    String a=x.toString();


    getString() method eka use karanne database table eken result set ekata ganna data retrieve karanna

    EX: String a="";
    Resultset rs=stmt.executeQuery("query")
    while(rs.next())
    {
    a=rs.getString(1);
    }

    Retrieves the value of the designated column in the current row of this ResultSet


    a=rs.getString(1);


    meke [getstring(1)] 1 n wenne mokakkda??? :):)
     

    Core

    Member
    Jan 23, 2010
    3,120
    195
    0
    Milky Way/Local Cluster/Local Sol/Earth
    Resultset rs=stmt.executeQuery("query")
    while(rs.next())
    {
    a=rs.getString(1);
    System.out.printlin(a); //new line
    }

    he declared a variable of Resultset Class then named it as rs
    next access to all records one by one (used next method for that) by using a loop
    and assign them to a string variable.
    so the getString() is a method of Resultset class
    I saw it's a Java not .NET language.

    now use
    System.out.printlin(a) to see the result one by one

    I guess
    stmt variable may be declared using the same Class but not sure
    I don't know much about Java.
     

    AncientGlory

    Member
    Jan 18, 2010
    1,131
    67
    0
    Australia
    a=rs.getString(1);


    meke [getstring(1)] 1 n wenne mokakkda??? :):)

    Assuming you are talking about java....

    It seems that getString method access an object matrix and the '1' corresponds to the column number of the current row of the object.

    To see how this works compile a small program with java and check. I don't have a java compiler with me right now..
     

    amilabanuka

    Well-known member
  • Sep 30, 2006
    7,291
    878
    113
    Thama math hoyanooo....
    toString() returns an string representation of an object. if it is a plain object then normally you will get the object ID. for customization you can override this method to return the String you wanted.