Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

tag

sql:setDataSource tag

JSP Standard Label LibraryJSP Standard Tag Library

sql:setDataSourceThe tag is used to configure a data source or store data source information in a variable in a scope, to serve as the data source for other JSTL database operations.

Syntax format





property

sql:setDataSourceThe tag has the following attributes:

property Description Whether it is required Default value
driver The JDBC driver to register No None
url The JDBC URL of the database connection No None
user Database username No None
password Database password No None
dataSource The database prepared in advance No None
var The variable representing the database No The default setting
scope The scope of the var attribute No Page

Example Demonstration

Set up the MySQL database:

The above parameters are very basic in MySQL or other databases, and it is best to memorize them. Next is a simple example using thesql:setDataSourcetag:



<%@ 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"%>





JSTL sql:setDataSource Tag





 







 





You will use it in other SQL tags sql:setDataSource tag.


JSP Standard Label LibraryJSP Standard Tag Library