TOC PREV NEXT INDEX



Create the database query


Next, we will create the code that the servlet will run when it receives a new query.

  1. Select the doGet section of the Servlet methods by choosing 'doGet' from the choicebox to the left of the Code Sourcerer button.
  2. Type the following code:
String newQuery = "SELECT FIRST_NAME, YTD_SALES "+
"FROM PUBLIC.SALES_REP_TBL "+
"WHERE FIRST_NAME LIKE '%" + s + "%'";

Be sure to hit return after the last ;. Take a moment to double-check that you typed this in correctly; if it is incorrect the servlet will not work properly.

  1. Press the 'Code Sourcerer' button.
  2. Choose 'JDBC Operations...'. Press Next.
  3. Choose 'Perform a Search...'. Press Next.
  4. Choose the last option, 'the following variable expression'. Erase the initial value and type 'newQuery' in the field to the right. Press Next.
  5. The last page has other settings. Do not change any of the settings on the page. Press done.

The Code Sourcerer will generate several lines of code which will execute a search and store the result in a two-dimensional array of Strings named 'tableData'.


Data Representations, Inc.
http://www.datarepresentations.com
support@datarepresentations.com
sales@datarepresentations.com
TOC PREV NEXT INDEX