Hip Hip Array
Hip Hip Array

Reputation: 4773

sqlite: not returning email address (org.sqlite.RS)

I have a email column in my database which contains the users email address, i can use the following statement

select email from student where fname = 'john' and lname = 'daly'

when i call this using the following code

 String result = null;
        connection = ConnectDb();
        stat = connection.createStatement();
        ResultSet rs = stat.executeQuery(sql);
    while(rs.next())
   {
    result =rs.getString(0);
    }

        closeAll();            
        return result;

i get the following result org.sqlite.RS@546984, im guessing this is because i need to return the result as a resultSet, i can do this for multiple values but i cannot figure it out for just a single value

Any know how to do this?

Upvotes: 0

Views: 117

Answers (1)

kosa
kosa

Reputation: 66657

It should be something like thi:

//Any way you know only one will be returned, so while excute only once.

   ResultSet rs = stat.executeQuery(sql);
    while(rs.hasNext())
   {
    result =rs.getString("email");
    }

Upvotes: 1

Related Questions