jstl_sql_ex.jsp
페이지 정보
본문
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<html>
<head>
<title>JSTL sql 라이브러리 사용 예제</title>
</head>
<body>
<sql:setDataSource
var="conn"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test?serverTimezone=UTC"
user="root"
password="1111"/>
<sql:update dataSource="${conn}">
INSERT INTO test (num, name) VALUES (1, '일돌이')
</sql:update>
<sql:update dataSource="${conn}">
INSERT INTO test (num, name) VALUES (2, '이돌이')
</sql:update>
<sql:update dataSource="${conn}">
INSERT INTO test (num, name) VALUES (3, '삼돌이')
</sql:update>
<sql:update dataSource="${conn}">
INSERT INTO test (num, name) VALUES (4, '사순이')
</sql:update>
<sql:query var="rs" dataSource="${conn}">
SELECT * FROM test WHERE name=?
<sql:param>사순이</sql:param>
</sql:query>
<c:forEach var="data" items="${rs.rows}">
<c:out value="${data['num']}"/>
<c:out value="${data['name']}"/>
<br>
</c:forEach>
</body>
</html>
- 이전글test 테이블 작성 21.07.15
- 다음글● JSTL(JSP Standard Tag Library) xml 21.07.15
댓글목록
등록된 댓글이 없습니다.