Code example for ResultSet

Methods: getDate, getDouble, getInt, next

0
		try{ 
			connect(); 
			PreparedStatement pst = conexao.prepareStatement("select datediff(project_end_date, project_start_date) as timeProj, project_start_date as sd, project_end_date as ed, project_target_budget as b from dotp_projects where project_id = ?");
			pst.setInt(1, id);
			ResultSet rs = pst.executeQuery();
			if (rs.next()){
				if (rs.getInt(1) != 0){											//garantir que a data seja válida (NÃO NULA)
					p.setStartDate(rs.getDate("sd"));
					p.setEndDate(rs.getDate("ed"));					
					p.setTime(rs.getInt("timeProj"));
				} 
				p.setBudget(rs.getDouble("b"));
			} 
			conexao.close();
		}	catch (SQLException e){ e.printStackTrace();}
		return p;
	} 
	 
}