Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Querying a Database Table


In this section, the database table created and modified in the previous sections will be queried, and the result is displayed in a HTML table. Create a JSP, catalogQuery.jsp. Select the JSTL Core 1.1 and JSTL SQL 1.1 tag libraries for the JSP. As in the previous sections, add a setDataSource tag for obtaining a connection with the Oracle database. The SQL taglib tag to query a database is sql:query. Position the cursor in the JSP page, and select Query tag in the SQL Component Palette.

In the Insert Query window, specify the var attribute, which is a required attribute. The var attribute specifies the variable for the result set returned by the Query tag. Select the Advanced Properties tab.

Specify the SQL query in the sql attribute field and click on the OK button.

The sql:query tag gets added to the JSP page:

<sql:query var="catalog" sql="SELECT * FROM CATALOG"/>

Add a<table> to display the result set of the Query tag. Add the table headers. A...