Once you have verified that the Database Connector is up and running, you are now ready to configure the database connector to work with your own database.
There are 2 options:
- Copy the configuration from your previous installation and the connector will continue to function as it did before. The latest database connector runs seamlessly with the DB Connector v2.4 configuration files. See the Database Connector Upgrade Guide for instructions.
- Read the documentation below for new configuration instructions to take advantage of the new features.
On this page:
Configuring Datasources
Datasources can be defined in 3 places:
- In configuration.xml
- In dbconnector.properties in the <db-home>\database\database-connector-2.5.1\config (standalone) or dbconnector.properties located in <frevvo-home>\tomcat\conf directory (bundle)
- In tomcat/conf/Catalina/localhost/context.default.xml as a <Resource>
The recommended approach to configuring datasources for both standalone and the tomcat bundle installations is described here. This approach separates the configuration.xml from the underlying infrastructure database and related credentials.
Configuring the v2.5.1 connector in the tomcat bundle
When deploying the connector in the tomcat bundle, the relevant configuration files are:
- dbconnector.properties - this file is used to define database resources and configuration properties.
- configuration.xml - define your database querysets and queries in this file
Follow these steps:
- These instructions assume you have already installed the tomcat bundle and the Database Connector and have verified that the connector up and running.
- Stop if it is running. You do not have to stop the Insight Server.
Navigate to the <frevvo-home>\tomcat\conf directory. Create a file named dbconnector.properties. This file will contain database connector configuration properties and datasource information.
Add the frevvo.connectors.database.configurations property to specify the path to your configuration.xml file. Use the forward slash - \ - in the path as the backslash in a properties file must be escaped.
Define datasources for each query set in your configuration.xml
Here is an example if you are using MySQL:
frevvo.connectors.database.configuration=file:///C:/frevvo/config/configuration.xml dbconnector.queryset@myStore.resource-def.url=jdbc:mysql://localhost:3306/classicmodels?createDatabaseIfNotExist=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useServerPrepStmts=true dbconnector.queryset@myStore.resource-def.user=root dbconnector.queryset@myStore.resource-def.password=root dbconnector.queryset@BIRT.resource-def.url=jdbc:mysql://localhost:3306/classicmodels?createDatabaseIfNotExist=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useServerPrepStmts=true dbconnector.queryset@BIRT.resource-def.user=root dbconnector.queryset@BIRT.resource-def.password=root
Let's take a look at the properties in this example:
- the frevvo.connectors.database.configuration property specifies the path to your custom configuration.xml file. Be sure to use the forward slash - \ - in the path even if you are running on the Windows Operating system.
- the next section provides the resource URL, database user and password for the myStore queryset defined in the configuration file.
- the next section provides the resource URL, database user and password for the BIRT queryset
- A database URL is a Universal Resource Locator (URL) that specifies a particular type of database server (compatible with the JDBC driver you installed. In addition you can also specify the database name to use for the connection.
The format for the database URL is database driver specific. For example, the correct format for a MySQL database is:
jdbc:mysql://[host][:port optional]/[database name]
Check with your database administrator or the documentation for your database drive for details on the correct database URL format.
- You can add other parameters to the URL. For examle, it is recommended that you add the useServerPrepStmts=true parameter to the database connection URL if you are using MySQL as your external database. This property improves the queryset/query validation if a column or table is missing. With this parameter in place, the MySQL driver reports a warning that the table or column doesn't exist.
- Validation sql and drivers are automatically selected by the database connector. There is no need to explicitly set them in the datasource definitions
- If you prefer to define your datasources on the container level, refer to the Defining the Data Source with Resource-ref topic. This approach is only supported in the tomcat bundle.
Examples of Datasource Definitions in the dbconnector.properties file
You can add other properties to this file. For example, If you want to change the loglevel for the database-connector.YYYY-MM-DD logfile when creating and troubleshooting queries for your forms/flows, add the spring.profiles.active property as shown below. This property loads a profile called dev which sets the loglevel to DEBUG. Refer to Logfiles for more details about logging options.
spring.profiles.active=dev
Create a subfolder named config under your <frevvo-home> directory i.e. c:\frevvo\config.
Create your configuration.xml file in the config directory or the location specified in the frevvo.connectors.database.configurations parameter in the dbconnector.properties file. Querysets/queries are defined in this file. Add the contents below, which defines querysets named myStore and BIRT, to your configuration.xml file to get you started.
<dbconnector> <queryset name="myStore"> </queryset> <queryset name="BIRT"> </queryset> </dbconnector>
Refer to the Defining SQL Queries topic for detailed information about the configuration.xml file content.
- Verify that you:
- Navigated to the <frevvo-home>\frevvo\ext\connectors directory.
- Unzipped the database.zip file to a temporary location of your choice: e.g. c:\tmp. This will create a folder c:\tmp\database. We'll refer to this directory below as <db-tmp>
- Copied the <db-tmp>\database\database-connector-2.5.0\database.war to <frevvo-home>\tomcat\webapps folder.
- Installed the JDBC driver
Start and the Insight server if necessary
.Browse the http://localhost:8082/database/status page
- Verify that query validation page is loaded with status Passed and is pointing to your custom configuration.xml file.
Configuring the v2.5.1 connector in Standalone mode
When deploying the connector in Standalone mode, the relevant configuration files are:
- dbconnector.properties - this file is used to define database resources and configuration properties.
- configuration.xml - define your database querysets and queries in this file
Follow these steps:
- Verify that you have
- Downloaded the Standalone connector zip file.
- Unzipped the database.zip file to a location of your choice. We will refer to this directory as <db-home>
- Installed the JDBC driver, if required.
Edit the dbconnector.properties in the database\database-connector-2.5.1\config directory of the standalone installation. The dbconnector.properties file is where you can customize database connection properties (such as server port) and configure datasource definitions. Add the datasource definitions for your querysets/queries to this file then save it.
Here is an example if you are using MySQL:# Customize the DbConnector here logging.file=./logs/database-connector.%d{yyyy-MM-dd}.log server.port=8081 dbconnector.queryset@myStore.resource-def.url=jdbc:mysql://localhost:3306/classicmodels?createDatabaseIfNotExist=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useServerPrepStmts=true dbconnector.queryset@myStore.resource-def.user=root dbconnector.queryset@myStore.resource-def.password=root dbconnector.queryset@BIRT.resource-def.url=jdbc:mysql://localhost:3306/classicmodels?createDatabaseIfNotExist=true&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useServerPrepStmts=true dbconnector.queryset@BIRT.resource-def.user=root dbconnector.queryset@BIRT.resource-def.password=root
Let's take a look at the properties. You must provide the resource information for each queryset in your configuration.xml file.
- the server.port property specifies the port number that your database is using.
- the next section provides the resource URL, database user and password for the myStore queryset
- the next section provides the resource URL, database user and password for the BIRT queryset
- A database URL is a Universal Resource Locator (URL) that specifies a particular type of database server (compatible with the JDBC driver you installed or was pre-installed in database\WEB-INF\lib) and a particular host. In addition you can also specify the database name to use for the connection.
The format for the database URL is database driver specific. For example, the correct format for a MySQL database is:
jdbc:mysql://[host][:port optional]/[database name]
Check with your database administrator or the documentation for your database drive for details on the correct database URL format.
- Add the useServerPrepStmts=true parameter to the database connection URL if you are using MySQL as your database. This parameter is needed to improve the queryset/query validation if a column or table is missing. With this parameter in place, the MySQL driver reports a warning that the table or column doesn't exist.
Create your configuration.xml file in the <db-home>\database\database-connector-2.5.1\config directory. Add the contents below, which defines querysets named myStore and BIRT, to your configuration.xml file to get you started.
<dbconnector> <queryset name="myStore"> </queryset> <queryset name="BIRT"> </queryset> </dbconnector>
Refer to the Defining SQL Queries topic for detailed information about the configuration.xml file content.Restart the connector using one of these methods:
Open a command prompt and navigate to the <db-home>\database\database-connector-2.5.0 directory
Type java -jar database.warOr If you installed the Database Connector as a service, click the Restart-DBConnector-Service.bat,sh to restart the service for your operating system. Click below for a list of the batch files and shell scripts that come with the connector.
Browse the http://localhost:8081/database/status page
Verify that query validation page is loaded with status Passed and is pointing to your custom configuration.xml file.
Defining the Data Source with Resource-ref in the tomcat bundle
Using <Resource-ref> to define datasources is not supported if you are running the Database Connector in Standalone mode. Use <Resource-def> instead.
Follow these steps:
- Edit <frevvo-home>\tomcat\conf\Catalina\localhost\context.xml.default,
Add the Resource name parameter. An example is shown below:
<Resource name="jdbc/<your database name>" auth="Container" driverClassName="com.mysql.jdbc.Driver" username="<your database user>" password="<your database password>" type="javax.sql.DataSource" url="jdbc:mysql://localhost/<your queryset name>?autoconnect=true"/>
Edit frevvo\tomcat\conf\dbconnector.properties file. Verify the Add the frevvo.connectors.database.configuration property has been set and Add the dbconnector.resource-ref.name property as shown below:
dbconnector.queryset@BIRT.resource-ref.name=jdbc/<name of your resource>
Disabling a QuerySet/Query
When you are developing your integration, you might want to disable a particular queryset/query so you can focus on the one you are troubleshooting. QuerySets/queries can be disabled in one of two ways:
Add the enable="true" attribute with a value of false to the <querySet/> or individual <query> elements in the configuration.xml file to completely disable it.
<dbconnector> <querySet name="BIRT" enabled="false" ...>
The same can be done in a dbconnector.properties file by following the XML structure. The property shown below uses the @BIRT selector to set the enabled attribute to false only for the BIRT querySet.
dbconnector.querySet@BIRT.enabled=false
This property disables all querysets
dbconnector.querySet.enabled=false