The selectAction( ) method

//  A JDBCExamples method to retrieve a certain row 
//  of the 'xmp' table.
//  This method illustrates prepared statements, parameter markers,
//  and result sets.

    public static String selectAction(Connection con)  
           throws Exception {

        String sql = "select name, home from xmp where id=?";
        int id=1;
        Address home = null;
        String name = "";
        String street = "";
        String zip = "";
        PreparedStatement pstmt = con.prepareStatement(sql);
        pstmt.setInt(1, id);
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
           name = rs.getString(1);
           home = (Address)rs.getObject(2);                 
           if (rs.next()) {
              throw new Exception("Error:  Select returned
 				 multiple rows");
           } else { // No action
           }         
        } else { throw new Exception("Error:  Select returned no rows"); 
        }                  
        return "- Row with id=1:  name("+ name + )   
                + " street(" + home.street + ) zip("+ home.zip + );