An database element allows you to query a back-end database and display the results in a portlet.
Creating a database element
Log in to Web Studio, select Build | Portlets, and right-click in the detail view and select New Aggregated Portlet.
When the Portlet Builder appears, right-click in either frame and select New Database Element from the Element Menu. You can also click the down arrow next to the Add icon and select Database Element.
Complete the Database Element Definition.
This example uses an Adaptive Server Anywhere database.
Username – enter the user name used to access the database; for example, to access Adaptive Server Anywhere, the default user name is:
dba
Password – enter the password used to access the database; for example, the default password for the Adaptive Server Anywhere database is:
SQL
JDBC Connect URL – enter the connection string to access the database; for example:
jdbc:sybase:Tds:localhost:port/portaldatabase
where localhost is the name of installed database server, port is the port used to connect to the specified database, and portaldatabase is the name of the database to which you want to connect.
For example, if the database server is installed on “tahiti” and the port used to connect to Adaptive Server Anywhere is 6100, you would enter:
jdbc:sybase:Tds:tahiti:6100/ASANY8
If the database server is installed on the same machine
as EP, you do not have to change the “localhost” value.
JDBC Driver – enter the JDBC driver used to access the database; for example:
com.sybase.jdbc2.jdbc.SybDriver
SQL query string – enter the SQL statement to retrieve the requested data from the database. For example, the simple query shown below displays everything.
select *
UI XSLT – (optional) enter the complete URL of the XSLT to be applied to the content returned by the database or click Select to choose from existing XSL templates.
Click Preview to see the query results.
Click Next in the upper-right corner to display the Split window. Split columns or rows using delimiters. See “Adding split rules”.
Click Next to display the Define window. Define the record layout and specify a record header. See “Defining record layout”.
Click Next to display the Filter window. Specify filter rules to select only the relevant data from the element. See “Adding filter rules”.
Click Next. The next page displays the element’s CGI parameters. See “CGI parameters” and “Using the database table adapter”.
Click Next to display the Element Name input field.
Enter a descriptive name.
Click Finish to close the window and display the Portlet Builder with the new database element.
Regardless of the element type, the procedure to save the element and portlet is the same. See “Saving portlets”.
See Chapter 10, “Building Pages,” for instructions on adding portlets
to pages.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |