JSTL-SQL <sql:query>タグ
属性
Attribute | Description | Required | Default |
---|---|---|---|
sql | SQL command to execute (should return a ResultSet) | No | Body |
dataSource | Database connection to use (overrides the default) | No | Default database |
maxRows | Maximum number of results to store in the variable | No | Unlimited |
startRow | Number of the row in the result at which to start recording | No | 0 |
var | Name of the variable to represent the database | No | Set default |
scope | Scope of variable to expose the result from the database | No | Page |
例
基本的な概念から開始するには、TESTデータベースに Employees テーブルを作成し、次のようにそのテーブルにいくつかのレコードを作成します。
次の手順に従って、Employeesテーブルを作成します-
ステップ1
- コマンドプロンプト*を開き、次のようにインストールディレクトリに変更します-
ステップ2
次のようにデータベースにログインします
ステップ3
次のように TEST データベースに Employee テーブルを作成します− −
データレコードを作成する
次のように、Employeeテーブルにいくつかのレコードを作成します-
次のように<sql:query> *を使用してSQL SELECTステートメントを実行するJSPを作成します。
上記のJSPにアクセスすると、次の結果が表示されます-