For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
SQL adapter connectionPolicy element
The connectionPolicy element of the adapter-descriptor file lets you configure settings for our adapter's SQL connection.
This page describes only the connectionPolicy element of the adapter-descriptor file. For information about other elements, see The JavaScript adapter-descriptor file.
Structure
The connectionPolicy element has two options for connection:
- The dataSourceDefinition subelement for development mode
- The dataSourceJNDIName subelement for production mode
Attributes
The connectionPolicy element has one attribute:
- xsi:type
Mandatory.
The value of this attribute must be set to sql:SQLConnectionPolicy.
Subelements
The connectionPolicy element must contain one of the following two subelements.
- dataSourceDefinition
Optional
Contains the parameters that are needed to connect to a data source. The adapter creates a connection for each request.
For example:
<connectionPolicy xsi:type="sql:SQLConnectionPolicy"> <dataSourceDefinition> <driverClass>com.mysql.jdbc.Driver</driverClass> <url>jdbc:mysql://localhost:3306/mysqldbname</url> <user>user_name</user> <password>password</password> </dataSourceDefinition> </connectionPolicy>
dataSourceJNDIName Optional.
Connect to the data source by using the JNDI name of a data source that is provided by the application server. The adapter takes the connection from the server connection pool that is associated with the JNDI name.
Application servers provide a way to configure data sources. For more information, see Install MobileFirst Server to an application server. For example:
<connectionPolicy xsi:type="sql:SQLConnectionPolicy"> <dataSourceJNDIName>my-adapter-ds</dataSourceJNDIName> </connectionPolicy>
Parent topic: The JavaScript adapter-descriptor file