Element Specifications for Cisco Unified CVP VXML Server and Cisco Unified Call Studio Release 9.0(1)
Database
Downloads: This chapterpdf (PDF - 1.25MB) The complete bookPDF (PDF - 3.36MB) | The complete bookePub (ePub - 559.0KB) | Feedback

Database

Database

The database element provides the ability to execute an SQL command on external databases within a voice application call flow. The element requires JNDI to be configured in the Java application server to handle database connections. Only a single SQL statement can be executed per element. There are four types of commands that can be made:

  • Single – This is used to run a SQL query that returns only a single row. Element data will be created with the variable names being the names of the columns returned and the value of that column as the element data value (as a string). If no row is returned, no element data will be set.

  • Multiple – This is used to run a SQL query that returns multiple rows. A Unified CVP-defined Java data structure, the Java class ResultSetList, stores the full result and is placed in session data. If no rows are returned, the ResultSetList object in session data will be empty. For detail about the ResultSetList data structure, refer to the javadocs for this class.

  • Inserts – This is used to run a SQL INSERT command that inserts information into the database.

  • Updates – This is used to run a SQL UPDATE command that updates information in the database.

The developer can utilize substitution to create dynamic queries. The Database element is ideal for performing simple queries and updates. It may not be sufficient for performing complex database interactions such as multiple dependent queries or stored procedure calls. One would use a custom configurable or generic action element for these tasks. Also note that in order to avoid performance issues creating database connections, implementing database pooling on the application server is highly recommended. Refer to http://docwiki.cisco.com/wiki/Unified_CVP_VXML_Server_JNDI_Resources for additional information on configuring Tomcat JNDI resources.

Settings

Name (Label)

Type

Req'd

Single Setting Value

Substitution Allowed

Default

Notes

type

(Type)

string enum

Yes

true

true

single

The type of query: single, multiple, insert or update.

jndiName

(JNDI Name)

string

Yes

true

true

None

This JNDI name for the SQL datasource of the database.

key

(Session Data Key)

string

Yes

true

true

None

For queries of type multiple, the name of the session variable which the results of the query will be stored.

query

(SQL Query)

string

Yes

true

true

None

The SQL query to be executed.

Element Data

Element data is created only when the type setting is set to single. Element data given the names of the return columns are created containing the respective return values. For example, if a query returned the following information:

foo bar

123 456

The following element data will be created: foo with the value 123 and bar with the value 456.

Session Data

Session data is created only when the type setting is set to multiple. In all other cases, no session data is created.

Name

Type

Notes

[value of setting "key"]

ResultSetList

The Java data structure that stores the returned values from a multiple type query. The name of the session data variable is specified by the developer in the key setting.

Exit States

Name

Notes

done

The database query was successfully completed.

Folder and Class Information

Studio Element Folder Name

Class Name

Integration

com.audium.server.action.database.DatabaseAction

Events

Name (Label)

Notes

Event Type

Java Exception event handler type can be selected.

Create JNDI Database Connection in Tomcat for Use in VXML Applications

Summary

Steps

This section explains how to create a new JNDI database connection in Tomcat. These instructions are useful when you would like to use the built-in Studio Database element, or create some custom code that accesses database functionality through JNDI.

  1. In order enable database access on your application server, a compatible JDBC driver must be installed. These drivers, typically packaged as JAR files, should be placed in a directory accessible to the application server classpath (on Tomcat, for example, place in %CVP_HOME%\VXMLServer\Tomcat\lib).
    Note    The database must exist for this connection to work. CVP VXML Server will not create the database for you.
  2. Add a Tomcat Context for the database connection so that the CVP VXML Server knows how to communicate with your database. Follow the instructions provided here.
  3. In Audium Builder for CVP Studio, edit the configuration of the Database element in question. Enter the string you entered below in <LABEL_YOU_CHOOSE> from the Tomcat Context into the JNDI Name property of the Settings tab of your Database element.
    Note    You should not include the jdbc/ portion here.
    Here is an example that uses MySQL (edit context.xml from AUDIUM_HOME\Tomcat\conf folder):
  • <Context>
    <Resource name="jdbc/<LABEL_YOU_CHOOSE>" 
    auth="Container"
    type="javax.sql.DataSource" 
    username="USER_NAME" 
    password="USER_PW"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://HOSTNAME_OR_IP:PORT/DB_NAME" />
    </Context>

The default port number for MySQL is 3306. An example url for the above Context would be jdbc:mysql://localhost:3306/DB_name

Note    Alternately, the <Resource> can be configured in the server.xml file under <GlobalNamingResources>, and a <ResourceLink> created in context.xml under <Context>

4. Under heavy load conditions, enable Database Connection Pooling.

A database connection pool creates and manages a pool of connections to a database. Recycling and reusing already existing connections to a database is more efficient than opening a new connection. For further information on Tomcat Database Pooling please see.