Hi all,
Iam trying to return a value from a resultset to be used in a jsp textbox. The problem i am having is that this value is hidden within the try..catch block and can not be returned. i have tried using the "throws SQLException" statement but with no success. Please is there any other way i can achieve this?? The jsp calls this method (below) to retrieve the required value:
public String getValue1(String record)
{
ResultSet rs = null;
String value1;
try
{
String sql = "SELECT column1 FROM myTable WHERE RecordNumber= '" + record + "'";
//
rs = theStatement.executeQuery(sql);
while (rs.next())
{
value1 = new String(rs.getString("column1"));
return value1;// <--not working
}
}
catch (SQLException sqle) {
System.err.println("Error Retrieving record" +sqle);
}
return value1; // <----error "variable might not have been initialized"
}