The code snippet below fetches all the rows that matches the criteria in where clause.

Java Code:
String name = cust_name.getText();
try {
  Statement stmt;
  String sql;

  sql =  "select custName from tCust where custName = "
     += "'" + name + "'";
  stmt = theConn.createStatement();
      
  ResultSet rs;
  rs = stmt.executeQuery();
       
  while (rs.next()) {
    System.out.println(rs.getString("custName"));
    }
  rs.close();
  stmt.close();
  }
catch (Exception e) {
  e.printStackTrace();
}