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 12 and Chapter 24 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
Attribute name |
Java type |
Dynamic value accepted |
Description |
dataSource |
String or javax.sql.DataSource |
Yes |
The data source to expose. If specified as a
|
url |
String |
Yes |
The JDBC URL. |
driver |
String |
Yes |
The JDBC driver class name. |
user |
String |
Yes |
The database username. |
password |
String |
Yes |
The database user password. |
var |
String |
No |
The variable name. If omitted, the data source configuration variable
is set. The type is either |
scope |
String |
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, 3rd 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.