Name
<sql:setDataSource>
Synopsis
The <sql:setDataSource>
action sets the data source configuration variable or
saves the data-source information in a scoped variable that can be
used as input to the other JSTL database actions.
This action is primarily intended for prototyping and small, simple applications. See Chapter 11 and Chapter 23 for alternative ways to make a data source available.
Syntax
<sql:setDataSource [dataSource="dataSource
" | url="url
" [driver="driverClassName
"] [user="username
"] [password="password
"]] [var="var
"] [scope="page|request|session|application"] />
Attributes
Attributename |
Java type |
Dynamic valueaccepted |
Description |
---|---|---|---|
dataSource |
|
Yes |
The data source to expose. If specified as a
|
url |
|
Yes |
The JDBC URL. |
driver |
|
Yes |
The JDBC driver class name. |
user |
|
Yes |
The database username. |
password |
|
Yes |
The database user password. |
var |
|
No |
The variable name. If omitted, the data-source configuration variable
is set. The type is either |
scope |
|
No |
The variable or configuration variable scope. |
Example
<sql:setDataSource var="snapshot" url="jdbc:odbc:snapshot" driver="sun.jdbc.odbc.JdbcOdbcDriver" /> <sql:query dataSource="${snapshot}" sql="..." var="result" />
Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.