JSTL - SQL - SQL - Update - Tag
JSTL - SQL - SQL - Update - Tag
Attribute
The <sql:update> tag has the following attributes −
Example
To start with basic concept, let us create a simple table Employees table in the TEST
database and create few records in that table as follows −
Step 1
Open a Command Prompt and change to the installation directory as follows −
C:\>
C:\>cd Program Files\MySQL\bin
C:\Program Files\MySQL\bin>
Step 2
Login to the database as follows −
https://www.tutorialspoint.com/jsp/jstl_sql_update_tag.htm 1/4
10/16/24, 4:06 PM JSTL - SQL <sql:update> Tag
Step 3
Create the table Employee in the TEST database as follows −
Learn SQL in-depth with real-world projects through our SQL certification course. Enroll
and become a certified expert to boost your career.
mysql>
https://www.tutorialspoint.com/jsp/jstl_sql_update_tag.htm 2/4
10/16/24, 4:06 PM JSTL - SQL <sql:update> Tag
Let us now write a JSP which will make use of the <sql:update> tag to execute an SQL
INSERT statement to create one record in the table as follows −
<html>
<head>
<title>JSTL sql:update Tag</title>
</head>
<body>
<sql:setDataSource var = "snapshot" driver = "com.mysql.jdbc.Driver"
url = "jdbc:mysql://localhost/TEST"
user = "root" password = "pass123"/>
https://www.tutorialspoint.com/jsp/jstl_sql_update_tag.htm 3/4
10/16/24, 4:06 PM JSTL - SQL <sql:update> Tag
</body>
</html>
+-------------+----------------+-----------------+-----------------+
| Emp ID | First Name | Last Name | Age |
+-------------+----------------+-----------------+-----------------+
| 100 | Zara | Ali | 18 |
| 101 | Mahnaz | Fatma | 25 |
| 102 | Zaid | Khan | 30 |
| 103 | Sumit | Mittal | 28 |
| 104 | Nula | Ali | 2 |
+-------------+----------------+-----------------+-----------------+
Similar way, you can try SQL UPDATE and DELETE statements on the same table.
https://www.tutorialspoint.com/jsp/jstl_sql_update_tag.htm 4/4