Name

<sql:dateParam>

Synopsis

The <sql:dateParam> action is used as a nested action for <sql:query> and <sql:update> update to supply a date and time value for a value placeholder. If a null value is provided, the value is set to SQL NULL for the placeholder. To ensure portability between different database engines, this action must be used when setting values for DATE, TIME, and TIMESTAMP columns.

The value must be of type java.util.Date or one of the SQL specific subclasses: java.sql.Date, java.sql.Time, or java.sql.Timestamp. If it’s a java.util.Date, the action converts it to the specified subclass.

Syntax

<sql:dateParam value="parameterValue" 
  [type="timestamp|time|date"] />

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

value
java.util.Date

Yes

The parameter value

type
String

Yes

The SQL type the value should be converted to, if needed

Example

<sql:update>
  UPDATE Employee SET EmpDate = ? WHERE EmpId = ?
  <sql:dateParam value="${empDate}" />
  <sql:param value="${empId}" />
</sql:update>

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.