<sql:setDataSource>标签用来配置数据源或者将数据源信息存储在某作用域的变量中,用来作为其它JSTL数据库操作的数据源。
<sql:setDataSource var="<string>" scope="<string>" dataSource="<string>" driver="<string>" url="<string>" user="<string>" password="<string>"/>
属性 | 描述 | 是否必要 | 默认值 |
---|---|---|---|
driver | 要注册的JDBC驱动 | 否 | 无 |
url | 数据库连接的JDBC URL | 否 | 无 |
user | 数据库用户名 | 否 | 无 |
password | 数据库密码 | 否 | 无 |
dataSource | 事先准备好的数据库 | 否 | 无 |
var | 代表数据库的变量 | 否 | 默认设置 |
scope | var属性的作用域 | 否 | Page |
以上参数在MySQL或其它数据库中是非常基础的,最好能够记住上面的参数。接下来给出一个简单的使用<sql:setDataSource>标签的例子:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ 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:setDataSource Tag</title> </head> <body> <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/TEST" user="user_id" password="mypassword"/> <sql:query dataSource="${snapshot}" sql="..." var="result" /> </body> </html>
您将会在SQL的其它标签中使用 <sql:setDataSource> 标签。
ASP.NET CheckBox TextAlign 属性 CheckBox 控件定义和用法 TextAlign 属性用于设置或返回 CheckBox 文本的对齐方式。 默认的对...
ASP.NET BorderWidth 属性 Style 控件定义和用法 BorderWidth 属性用于设置或返回控件的边框宽度。 语法asp:webcontrol id="id" ...
ASP.NET ListItem 控件 Web 服务器控件定义和用法 ListItem 控件可创建列表中的一个项目。 此控件与以下列表控件一同使用:asp:L...
在以下的内容中,你将了解什么是Razor?如何添加 Razor 代码?RazorC# 与 VB 的语法规则是什么?在本教程中,我们将使用 C# 和 V...
让我们编写一个简单的 Ruby 程序。所有的 Ruby 文件扩展名都是 .rb。所以,把下面的源代码放在 test.rb 文件中。 实例 #!/usr/bi...