0

so.. i created a function on mysql workbench for getting the age of a person from its birth date. On the mysql workbench i call the function like this:

SELECT get_age(fecha_nacimiento, NOW()) AS age
FROM pacientes
WHERE id_paciente = 2

An it give the correct answer, which is 2 on a column named "age"

but when i call it with jstl like this:

<sql:query var="edad" sql="select get_age(fecha_nacimiento, NOW()) as age from pacientes 
where id_paciente=2" dataSource="${con }" ></sql:query>
<c:out value="${edad.age}"/>

i got an error that says :

javax.el.PropertyNotFoundException: Propiedad 'age' no hallada en el tipo org.apache.taglibs.standard.tag.common.sql.ResultImpl

which i believe in english would be:

javax.el.PropertyNotFoundException: The class `org.apache.taglibs.standard.tag.common.sql.ResultImpl` does not have the property 'age'`

I already checked that everything used on the query exists on the DB and it does, any help would be highly appreciated

Oscar Or
  • 73
  • 9
  • You are trying to get the property 'age' from the entire query result object, whereas you should get it from the first (and only) row. – Richard Osseweyer Nov 21 '15 at 20:02
  • How long do you plan to design your JSP pages the wrong way? Here's a starting point: http://stackoverflow.com/q/5003142 – BalusC Nov 21 '15 at 20:34

0 Answers0