Section | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
...
- In configuration.xml
- In dbconnector.properties in the <db-home>\database\database-connector-2.5.2\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
...
Database Connector in the tomcat bundle
When deploying the connector in the tomcat bundle, the relevant configuration files are:
...
- 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:
Code Block 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
Note - 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
Expand title Click here for examples of dbconnector.properties files with datasources for some common databases MySQL example
A queryset named "alltest" against a MySql database named "test" running on localhost on the default port when the login for user "root" requires no password. You can add more parameters such as:
- createDatabaseIfNotExist=true - this property set to true will create an empty database if the specified one does not exist
- useServerPrepStmts=true - this property is recommended for MySQL database. With the property in place the driver reports a warning if a table or column does not exist
Code Block dbconnector.queryset@alltest.resource-def.url=jdbc:mysql://localhost:3306/test dbconnector.queryset@alltest.resource-def.user=<your database user id> dbconnector.queryset@alltest.resource-def.password=<your database password>
HSQLDB example
Here is an example that connects to an HSQLDB driver.
Code Block dbconnector.queryset@mystore.resource-def.url=jdbc:hsqldb dbconnector.queryset@mystore.resource-def.user=<your database user id> dbconnector.queryset@mystore.resource-def.password=<your database password>
SQL Example
Here is an example that connects to a SQL Server driver
Code Block dbconnector.queryset@BIRT.resource-def.url=jdbc:sqlserver://192.168.1.102;DatabaseName=mystore dbconnector.queryset@BIRT.resource-def.user=<yourUser> dbconnector.queryset@BIRT.resource-def.password=<yourPassword>
SQL jTDS Example
This Url connects to a SQL Server using the jTDS driver that works with Microsoft SQL 2008.
Code Block dbconnector.queryset@mystore.resource-def.url=jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db dbconnector.queryset@myStore.resource-def.user=<yourUser> dbconnector.queryset@myStore.resource-def.password=<yourPassword>
For SQL server, the database name can also be specified as part of the Url rather than using the DatabaseName optional parameter. For example if your database name is acswa and the SQL server is running on 59377:Code Block dbconnector.queryset@BIRT.resource-def.url=jdbc:jtds:sqlserver://<sqlhost>:59377/acswa
As of SQL 2000, Microsoft SQL allows installation of multiple SQL named instances. If your SQL server was installed this way you must use the instance parameter. For example if you database instance was named xyzzy:
Code Block jdbc:jtds:sqlserver://<sqlhost>:59377/acswa;instance=xyzzy
Oracle 11g
Here is an example that connects to an Oracle 11g driver.
Code Block dbconnector.queryset@mystore.resource-def.url=jdbc:oracle:thin:@localhost:1521:ServiceName dbconnector.queryset@myStore.resource-def.user=<yourUser> dbconnector.queryset@myStore.resource-def.password=<yourPassword>
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.
Code Block 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.
Code Block <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.
...
Defining the Data Source with Resource-ref in the tomcat bundle
Info |
---|
Using <Resource-ref> to define datasources is not supported if you are running the Database Connector in Standalone mode. Use <Resource-def> instead. |
...
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.
Code Block <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.
Code Block dbconnector.querySet@BIRT.enabled=false
This property disables all querysets
Code Block dbconnector.querySet.enabled=false
...