<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">The<i><b> <;sql:dateParam>;</b></i> tag is used as a nested action for <;sql:query>; and <;sql:update>; 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.</p>
<p> JSTL dateParam Tag provides the value of the date parameter. In SQL update statement, date paramter is sent using JSTL dateParam tag.</p>
<p> <b>Syntax</b><br />
<i><;sql:dateParam value=&#8221;<;string>;&#8221; type=&#8221;<;string>;&#8221;/>;</i></p>
<p><b>JSTL Param Tag has following attribute.</b></p>
<p><b>1. value Attribute:</b> Specifies the value of the date parameter.<br />
<b>2. type Attribute: </b>Specifies the type of the parameter. It can be DATE , TIME or TIMESTAMP. TIMESTAMP is the default value.<br />
<b><br />
</b> <b>JSTL SQL date param Tag Example:</b><br />
To start with basic concept, let us create a simple table Students table in TEST database and create few records in that table as follows:</p>
<pre class="highlight" name="code"><;%@ page import="java.io.*,java.util.*,java.sql.*"%>;
<;%@ page import="javax.servlet.http.*,javax.servlet.*" %>;
<;%@ page import="java.util.Date,java.text.*" %>;
<;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>;
<;%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>;
 
<;html>;
<;head>;
<;title>;JSTL sql:dataParam Tag<;/title>;
<;/head>;
<;body>;
 
<;sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
 url="jdbc:mysql://localhost/TEST"
 user="root" password="pass123"/>;

<;%
Date DoB = new Date("12-08-1987");
int empId = 1111;
%>;
 
<;sql:update dataSource="${snapshot}" var="count">;
 UPDATE Students SET dob = ? WHERE Id = ?
 <;sql:dateParam value="<;%=DoB%>;" type="DATE" />;
 <;sql:param value="<;%=studentId%>;" />;
<;/sql:update>;
 
<;sql:query dataSource="${snapshot}" var="result">;
 SELECT * from Students;
<;/sql:query>;
 
<;table border="1" width="100%">;
<;tr>;
 <;th>;Emp ID<;/th>;
 <;th>;First Name<;/th>;
 <;th>;Last Name<;/th>;
 <;th>;DoB<;/th>;
<;/tr>;
<;c:forEach var="row" items="${result.rows}">;
<;tr>;
 <;td>;<;c:out value="${row.id}"/>;<;/td>;
 <;td>;<;c:out value="${row.first}"/>;<;/td>;
 <;td>;<;c:out value="${row.last}"/>;<;/td>;
 <;td>;<;c:out value="${row.dob}"/>;<;/td>;
<;/tr>;
<;/c:forEach>;
<;/table>;
 
<;/body>;
<;/html>;
</pre>
</div>
<p><b>Now try to access above JSP, which should display the following result:</b></p>
<table border="1" style="width: 100%px;">
<tbody>
<tr>
<th>Emp ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>DOB</th>
</tr>
<tr>
<td>1111</td>
<td>Dinesh</td>
<td>Rajput</td>
<td>12-08-1987</td>
</tr>
<tr>
<td>2222</td>
<td>Sweety</td>
<td>Rajput</td>
<td>20-11-1989</td>
</tr>
</tbody>
</table>
<div style="background-color: pink; border-width: thin; text-align: center;"><b><;<;<a href="https://dineshonjava.com/2013/10/jstl-sql-param-tag-example.html">Previous</a> <;<; ; ; || <a href="https://dineshonjava.com/2013/10/jsp-standard-tag-library-jstl-tutorial.html">Index </a>||  ; >;>;<a href="https://dineshonjava.com/2013/10/jstl-sql-transaction-tag-example.html">Next</a> >;>;</b></div>
<p>
</div>
<div class="wp-post-navigation"> 
									 <div class="wp-post-navigation-pre"> 
									 <a href="https://dineshonjava.com/jstl-sql-param-tag-example/">Previous</a> 
									 </div> 
									 <div class="wp-post-navigation-next"> 
									 <a href="https://dineshonjava.com/jstl-sql-transaction-tag-example/">Next</a> 
									 </div> 
									</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
 $.post('https://dineshonjava.com/wp-admin/admin-ajax.php', {action: 'mts_view_count', id: '294'});
});
</script>
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…