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 foler, and select Create New Mobile Application With|Database Element.

  2. When the New Mobile Application wizard appears, select Launch Element Wizard, then select Database from the Element Type drop-down list, and click Finish.

  3. Complete the options in the Database Element dialog:

    • Database Connection Parameters – you can use the Enterprise Explorer within Sybase WorkSpace to create your connection profiles. When selecting a connection, you have two choices for database connection parameters:

      1. Connection Cache – the connection cache used to access the database. Select the JNDI reference from the drop-down list. These are created on the Unwired Accelerator server to which you are connected.

      2. Connection Profile – a JDBC connection profile to use to establish a connection to the database. Selecting a connection profile from the drop-down list fills in the following fields automatically, or you can manually fill in the fields:

        • Username – the user name used to access the database; for example, to access Adaptive Server Anywhere, the default user name is dba.

        • Password – the password used to access the database; for example, the default password for the Adaptive Server Anywhere database is SQL.

        • Connection URL – the connection string to access the database; for 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 change the "localhost" value.

        • JDBC Driver – the JDBC driver used to access the database; for example:

          com.sybase.jdbc2.jdbc.SybDriver
          

    • SQL Query – displays the SQL statement to retrieve the requested data from the database. If you import a .qry file (see Importing and Exporting Mobile Application Elements), the query from that file displays in the SQL Query field, or you can enter the query directly into the field. For example, the simple query shown below displays everything in the users table.

      select * from users
    • Validate – validates that your SQL code contains no errors. This is "Enabled" if you select a connection profile and true is returned if the SQL code is valid.

    • Visual SQL – allows you to visually generate SQL syntax without writing SQL code. You can create select, insert, update, and delete statements using Visual SQL. If a query already exists in the SQL Query screen, the query displays in the Visual SQL editor, where you can modify it as needed. This option is enabled only if you select a connection profile. Also, the SQL type is enabled only if you are creating SQL syntax for the first time, in other words, nothing exists in the SQL edit box. After creating SQL code, you can edit only select statements here.

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

    • UI XSLT – (optional) the complete URL of the XSLT to apply to the content returned by the database. You cannot edit this field. Use the Search button to choose an existing XSL template.

  4. Click Next. Depending on the SQL code, you may or may not see the Rules window.

  5. Click Finish to close the window and display Sybase WorkSpace with the new database element, or you can define rules or CGI parameters for the database element.

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