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
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.
When the New Mobile Application wizard appears:
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.
From Status, select the status of the mobile application.
Enter a name for the mobile application in Mobile Application Name.
Select Launch Element Wizard and select Database from the Element Type drop-down list.
Click Finish.
The New Mobile Application Element wizard opens.
Define the following, then click Next:
Database Connection Parameters
Element | Description |
---|---|
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
Element | Description |
---|---|
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.
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
Element | Description |
---|---|
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. |
Click Preview to view the data in a table.
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.
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.
Click Finish.
The mobile application displays under the status folder in which you created it.
Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com