Creating Database Elements

A database element allows you to query a back-end database and display the results in a mobile application.

Using Sybase WorkSpace to create database elements allows you to leverage other Sybase products that are integrated into Sybase WorkSpace to help create and build your database elements. The steps below describe how to create a database element using the database element wizard.

Creating a database element

  1. From the Mobile Development perspective, select File|New|Mobile Application. Alternatively right-click the Mobile Applications folder, and select Create New Mobile Application With|Database Element.

  2. When the New Mobile Application wizard appears:

    1. From Connection Profile, select a profile from the drop-down, or click Create Profile to create a new profile. See Creating an Unwired Accelerator Connection Profile.

    2. From Status, select the status of the mobile application.

    3. Enter a name for the mobile application in Mobile Application Name.

    4. Select Launch Element Wizard and select Database from the Element Type drop-down list.

    5. Click Finish.

      The New Mobile Application Element wizard opens.

  3. Define the following, then click Next:

    Database Connection Parameters

    ElementDescription

    Connection Cache

    Select the JNDI reference from the drop-down list.

    These are created on the Unwired Accelerator server to access the database.

    Connection Profile

    Select a JDBC connection profile to establish a connection to a JDBC database. If you select this option, you must complete the JDBC Information in the following section. If you do not want to use any of the existing database profiles, you can create your own and complete the JDBC information manually.

    JDBC Information

    ElementDescription

    Username

    Enter the user name to access the database.

    For example, to access Adaptive Server Anywhere, the default user name is dba.

    Password

    Enter the password to access the database.

    For example, the default password for the Adaptive Server Anywhere database is SQL.

    Connection URL

    Enter the URL to access the database, using the following example:

    jdbc:sybase:Tds:host:port/portaldatabase?ServiceName=portaldatabase

    where host 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.

    If the database server is installed on the same machine as Unwired Accelerator, you do not have to edit the value of the localhost.

    JDBC Driver

    Enter the JDBC driver used to access the database, using the following example:

    com.sybase.jdbc3.jdbc.SybDriver
    

    The SQL Query section allows you to write an SQL statement to retrieve data from the database.

    Note

    The Validate and Visual SQL fields are enabled only if you select a profile, or if the connection cache matches an existing profile created on the system. See the Unwired Accelerator Developer's Guide, Chapter 3 "Database Connection Cache Options" for more information.

    SQL Query

    ElementDescription

    Validate

    Click Validate to verify that your SQL statement contains no errors.

    Visual SQL

    Click Visual SQL to visually generate SQL syntax without writing SQL code. You can create select, insert, update, and delete statements using Visual SQL.

    If a query is entered in the text box, the query displays in the Visual SQL editor. You can edit as needed.

    See Using Visual SQL to Edit a Procedural Object for more information about Visual SQL.

    UI XSLT

    ElementDescription

    UI XSLT

    (Optional) Click Search to choose an existing XSL template to apply to the content returned by the database. You cannot edit this field.
  4. Click Preview to view the data in a table.

  5. Depending on the SQL code, you may or may not see the Rules window. See Using Rules and Record Layout if you see the Rules window. After defining the rules, click Next.

  6. Depending on the SQL code you entered, you may or may not see the Parameters window. See Setting CGI Parameters if you see the Parameters window. After defining the CGI parameters, click Next.

  7. Click Finish.

    The mobile application displays under the status folder in which you created it.

Configuring Mobile Applications

Setting CGI Parameters

Using Rules and Record Layout

Visual SQL and Database Elements

Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com