Oracle9iAS Portal Developer Kit
Installing the Feedback Portlet

Once you have successfully installed and deployed the PDK-Java Framework and samples, you may want to run the Feedback Portlet that comes with the Sample Provider. This JSP portlet accepts feedback from the user and inserts into the database. Before you can execute this portlet, you need to run a script that creates the database schema and table required by this portlet. You also need to configure a JDBC data source with the path "jdbc/feedback" that will provide the portlet with pooled connections to the appropriate database account.

This article describes how to configure the Feedback Portlet by setting up a database account , and specifying its JDBC connection details in the OC4J data sources configuration file . This could be useful when you need to build other portlets that need to talk to the database through JDBC connections.

ASSUMPTIONS

  1. You have installed the samples downloaded with PDK-Java and understand the steps required to display a Web portlet on an Oracle Portal page. For more information on installing the sample, please review the article on installing the PDK-Java Framework and Samples.
  2. You are using the Oracle OC4J J2EE container to execute and display servlets used by PDK-Java.
  3. You are using an Oracle 8.1.6 (or later) database.

CONFIGURING THE DATABASE

This section describes how to run the SQL script to create the schema and table required by the Feedback Portlet.
  1. Change to the "doc/feedback" directory located under the root of the JPDK application on your filesystem, (e.g. "C:\oc4j\j2ee\applications\jpdk\jpdk\doc\feedback\" ). Find the script named insfbtab.sql -- this script creates the database schema and table required by the Feedback Portlet.
  2.  
    create user feedback identified by feedback;

    alter user feedback default tablespace users;

    alter user feedback temporary tablespace temp;

    grant connect, resource to feedback;

    connect feedback/feedback;

    show user;

    create table feedback_details (

    CUSTOMER_NAME VARCHAR2(30),

    COMPANY_NAME VARCHAR2(30),

    FEEDBACK_TEXT VARCHAR2(500)

    );

  3. To create the feedback schema, use SQLPLUS to connect to your database with SYSDBA privileges and run the insftab.sql script that is located in the doc/feedback directory. If you are not aware of how to do this, ask your database administrator to do this for you.

ADDING JDBC CONNECTION FOR THE FEEDBACK PORTLET  IN OC4J DATA SOURCES

  1. Change to the directory j2ee/home/config located under your OC4J home directory. Find and open the file data-sources.xml. Add a new data source that can be used by the feedback portlet. The datasource should be configured to return pooled connections when accessed through the path "jdbc/feedback". For example:

    <data-source

      class="com.evermind.sql.DriverManagerDataSource"
      name="OracleDS"
      location="jdbc/feedbackCore"
      xa-location="jdbc/xa/feedback"
      ejb-location="jdbc/feedback"
      connection-driver="oracle.jdbc.driver.OracleDriver"
      username="feedback"
      password="feedback"
      url="jdbc:oracle:thin:@myHost.us.oracle.com:1521:mySID"
      inactivity-timeout="30"

     />

  1. Save the file data-sources.xml and verify that the file is saved under j2ee/home/config of your OC4J home directory.  You will need to restart OC4J, if already running for the changes to take effect.

  2.  

VIEWING THE FEEDBACK PORTLET

  1. Login to Oracle Portal and verify that the Feedback Portlet shows up along with the other portlets provided by the Sample Provider you installed with the JPDK in the Portlet Repository.
  1. Create a page with the Feedback Portlet.
  2. Enter details in the portlet and click "Submit your feedback".
  3. Check that the values are correctly inserted in the database.
    1. Login to the database, enter:     sqlplus feedback/feedback
    2. Check the data in the table FEEDBACK_DETAILS, enter:     
    3. select * from feedback_details;

    4. You should see the data you entered into this table. If you do not see the data, check the JDBC connection details you provided earlier. You will also see the SQL error message show up on the portlet itself. Fix the problem and try again until you can see the data in the table.
  4. You have now successfully run the Feedback Portlet.
Now that you have successfully executed this Feedback Portlet, you can use a similar approach when coding and running other Web portlets that interact with the database.  To learn more about how Java programmers can conveniently access relational data, please refer to further documentation on JDBC and SQLJ on OTN.

Revision History: