This guide provides instructions on setting up Flux with any of its supported databases.
Keeping Current with JDBC Drivers
Customers occasionally report issues with Flux and their databases, e.g., database exceptions, problems with reindexing, reorganizing their database, or database issues with performance and reliability. In many instances the database itself has been upgraded (new version or service packs and patches applied) but the JDBC driver that Flux is using has not. It is the customer's responsibility to ensure that the database driver in use with Flux is current in accordance with the database vendor's documentation. Do not use a database driver that predates the database version in use (e.g., do not use an Oracle Driver for Oracle 9 if your database is running Oracle 11).
- Preparing the Database for Flux to Connect
- Configuring Flux to Use the Database
- Database Configuration and Driver Settings
- SQL Server 2005, 2008 or 2012
- sendStringParameterAsUnicode: Java clients, including Flux, can experience performance problems when communicating to SQL Server using JDBC drivers. Most of the JDBC drivers pass string parameters to SQL Server as Unicode by default. This can cause the Unicode parameters to fail to recognize appropriate indexes for VARCHAR key columns, increasing unwanted table scans. Setting this parameter to false, as above, corrects this problem.
- Choosing the SQL Server JDBC JAR file
- SQL Server — Integrated Security
- Oracle RAC
Advanced Users (Java knowledge required)
This guide assumes that you are configuring Flux from a file (this would be the case if you are starting Flux from a service or a script). If you have instead created your Flux engine using the Java API, refer to Configuring Flux to Run With Databases Using the Java API for more details about configuring the engine through code.
Preparing the Database for Flux to Connect
The first thing you'll need to do is select the database you will want Flux to use. Flux supports any of the five database servers listed above. If you have more than one database server available and you are unsure which database will work best for Flux, see the Technical Specifications for performance metrics for each server, or see Databases for an in-depth look at how Flux works on each server.
Once you've chosen a database, you'll need to set up a schema for Flux to use. If you're not sure how to create a new schema on your database, the links below contain more information for each supported server:
For example, on MySQL, this might look like:
Where "Flux" is the name of the schema you want to create.
After your schema is created, you'll need to populate it with the Flux database tables. Flux includes .sql scripts for each database server type to automatically create the tables it requires – to set up the tables, you'll first just need to navigate to <Flux home>/doc and find the SQL script for your database (on MySQL, for example, this would be mysql.sql). Once you've located the correct script for your database, just execute that script using standard script execution methods on your server (to avoid permissions problems later on, be sure to run the script using the same user account that you will want Flux itself to use when connecting to the database).
Flux database permissions
Make sure the Flux database user has the permissions set as described in Database and File System Permissions.
If you're not familiar with the process for executing a script, you can find detailed instructions for each server type below:
On MySQL, for example, you might run the following command after connecting to the MySQL database using the command line tool:
Where "<Flux home>" is the full path to the directory where you've installed Flux.
For Additional Database Setup Details
For additional specifics regarding database setup details, refer to Databases for your specific database. This page contains details on additional commands or features that must be enabled or executed in order for Flux to perform as expected.
Advanced Users (SQL knowledge required)
NOTE: The SQL scripts provided impose size restrictions on some columns in the Flux tables. If you find that the data you need to store consistently exceeds these limitations, you may want to increase the size of those columns to match your needs.
Configuring Flux to Use the Database
- To get started, you will first need to download a JDBC driver for your database (see "Database Configuration and Driver Settings" below for a link to download your driver class if you do not already have one available).
Once you've downloaded the driver, place the driver .jar file into your <Flux home>/lib directory. Placing the file in this directory will allow the engine to easily locate the driver.
Edit the file engine-config.properties (which should be located in the <Flux home>/config directory) add the following lines:
MAX_CONNECTIONS and CONCURRENCY_LEVEL
You can change the MAX_CONNECTIONS and CONCURRENCY_LEVEL settings to match your needs. Be careful to ensure that MAX_CONNECTIONS is at least 5 higher than the engine configuration property CONCURRENCY_LEVEL, or (if a runtime configuration file is configured) the runtime configuration's property CONCURRENCY_THROTTLE. To read more about these properties, what they do, and how they relate to one another, see Max Connections and Concurrency Level.
Database Configuration and Driver Settings
SQL Server 2005, 2008 or 2012
SQL Server Options sendStringParametersAsUnicode and SelectMethod
SelectMethod=cursor: This connection string parameter was required in older versions of SQL Server. In all SQL Server versions supported in Flux, however, the parameter is only required if large results are returned from database queries (typically more than 100 records at a time) and Flux does not have sufficient memory to handle the result set. If this method is turned on, it avoids this problem by returning result sets at 100 rows per call, but at the expense of server performance.
You may disable this property in Flux to achieve significant performance gains. Testing shows that in a typical environment, performance gains of up to 40% are achieved by disabling this property alone.
Choosing the SQL Server JDBC JAR file
SQL Server offers two versions of the database driver. For more information on choosing which JDBC driver is right for your installation, see System Requirements for the JDBC Driver from Microsoft.
SQL Server — Integrated Security
If your SQL server database will reuse the security credentials of the user who starts Flux / starts the Flux engine service, you can run in integrated security mode. In this case, the parameters would look like:
With integrated security enabled, the JDBC_USERNAME and JDBC_PASSWORD parameters should not be set, as these will indicate to Flux that SQL authentication rather than Windows authentication will be used.
Finally, it is necessary to install the file sqljdbc_auth.dll into the Java installation. Typically, this can be done by copying the file into <Java home>/lib. For more information, see Building the Connection String from Microsoft.
Flux requires the READ COMMITTED transaction isolation level. You can enable this on your database by running the query below
To determine if this setting is enabled, run the following query. A return value of '1' indicates the feature is enabled.
Configuring Flux to use a Data Source from an Application Server
If Flux is running within the same application server as your data source, you can easily configure Flux to use a data source from that server by setting the DATA_SOURCE engine configuration property. You can also specify a username and password to connect to the data source if required, as well as other settings to control how Flux interacts with the data source (see the previous link for a full explanation of each data source property).
If Flux is running from outside your application server, you can still access the data source. You will just need to set the PROVIDER_URL and INITIAL_CONTEXT_FACTORY engine configuration properties (and, if your initial context factory requires it, the username and password for the factory). The provider URL and context factory settings instruct Flux on where to find the application server hosting the data source, and how it should connect to that data source.