Skip to Content
JavaServer Pages, Second Edition
book

JavaServer Pages, Second Edition

by Hans Bergsten
August 2002
Intermediate to advanced
688 pages
23h
English
O'Reilly Media, Inc.
Content preview from JavaServer Pages, Second Edition

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

String or javax.sql.DataSource

Yes

The data source to expose. If specified as a String, it can be either a JNDI path or a list of JDBC parameters as described for the data -source configuration setting.

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 javax.sql.DataSource or String.

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" />
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaServer Pages, 3rd Edition

JavaServer Pages, 3rd Edition

Hans Bergsten
Beginning JavaServer Pages™

Beginning JavaServer Pages™

Vivek Chopra, Sing Li, Rupert Jones, John T. Bell, Jon Eaves
JavaServer Faces

JavaServer Faces

Hans Bergsten

Publisher Resources

ISBN: 059600317XSupplemental ContentCatalog PageErrata