⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqldemo.jsp

📁 此资源是jsp应用开发 邓子云等编写的一书里的源代码
💻 JSP
字号:
<%@ page contentType="text/html; charset=GBK"%>
<%@ 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>sqldemo</title>
	</head>
	<body bgcolor="#ffffff">
		<h1>
			使用 SQL 标签库
		</h1>
		<c:set var="valprice" value="1000" />
		<sql:setDataSource
			driver="com.microsoft.jdbc.sqlserver.SQLServerDriver"
			url="jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=pubs"
			user="sa" password="" var="conn" />
		<sql:transaction dataSource="${conn}">
			<sql:update var="newTable">
				CREATE TABLE ProductDetails
				(
				ProductId int IDENTITY (1000, 1) NOT NULL primary key,
				ProductName varchar (20) NOT NULL ,
				ProductType varchar (15) NOT NULL ,
				Price varchar (5) NOT NULL ,
				Brand varchar (25) NOT NULL ,
				Description varchar (50) NOT NULL
				)
			</sql:update>
		</sql:transaction>
		<sql:update var="newrow" dataSource="${conn}">
			INSERT INTO ProductDetails(ProductName, ProductType,
			Price, Brand, Description)
			VALUES('JSP专家导学 ', '编程书籍', '1000', 'Lee', '适合大专院校的教材或参考书籍')
		</sql:update>
		<sql:query var="products" dataSource="${conn}">
			select * from ProductDetails
		</sql:query>

		<table border="1">
			<c:forEach items="${products.rows}" var="row">
				<tr>
					<td>
						${row.ProductName}
					</td>
					<td>
						${row.ProductType}
					</td>
					<td>
						${row.Price}
					</td>
					<td>
						${row.Description}
					</td>
				</tr>
			</c:forEach>
		</table>
	</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -