ResultSet Error

Hello all,

I am checking if a particular value exist in my first column.When obtained i want to display it ,but using result set getString() method i get error of cursor position..since my table value are unique my result set will always have 1 row .....so how to fetch this string in first coumn..

.....this is what i have done

//sql contains my search string

rs=stmt.executeQuery(sql);

if(rs.wasNull())

{

System.out.println("not found");

}

else

{

System.out.println("found: "+rs.getString("Value");

}

[857 byte] By [codeit@717a] at [2007-11-26 16:11:18]
# 1
can you print your stack trace
G_Abubakra at 2007-7-8 22:33:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
call rs.next() then u have to fetch by using rs.getString()
NAGARAJU.VARKALAa at 2007-7-8 22:33:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

rs=stmt.executeQuery(sql);

if(rs.next())

{

System.out.println("found: "+rs.getString("Value");

}

else

{

System.out.println("not found");

}

iklestevea at 2007-7-8 22:33:48 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...