Overview
The Database Connector provides functionality to retrieve data from JDBC-compatible relational databases and register it in the Fess index.
This feature requires the fess-ds-db plugin.
Supported Databases
All JDBC-compatible databases are supported. Main examples:
MySQL / MariaDB
PostgreSQL
Oracle Database
Microsoft SQL Server
SQLite
H2 Database
Prerequisites
Installation of the
fess-ds-dbplugin is requiredA JDBC driver compatible with the target database is required
Read access to the database is required
Proper query design is important when retrieving large amounts of data
Plugin Installation
Method 1: Place the JAR file directly
Method 2: Install from the admin console
Open “System” -> “Plugin”
Upload the JAR file
Restart Fess
Installing JDBC Drivers
Place the JDBC driver compatible with your target database in the Fess classpath (app/WEB-INF/lib/ directory):
After placing the JDBC driver, restart Fess to load it.
Configuration
Configure in the admin console under “Crawler” -> “Data Store” -> “Create New”.
Basic Settings
| Item | Example |
|---|---|
| Name | Products Database |
| Handler Name | DatabaseDataStore |
| Enabled | On |
Parameter Configuration
MySQL/MariaDB example:
PostgreSQL example:
Parameter List
| Parameter | Required | Description |
|---|---|---|
driver | Yes | JDBC driver class name (if not specified, a DataStoreException is raised) |
url | Yes | JDBC connection URL (required for connection) |
sql | Yes | SQL query for data retrieval (if not specified, a DataStoreException is raised) |
username | No | Database username |
password | No | Database password |
fetch_size | No | JDBC fetch size. Set to MIN_VALUE for MySQL streaming result sets |
default_mimetype | No | Default MIME type used when extracting content from BLOB or binary columns |
column_label.mimetype | No | Column name that contains the MIME type used for extracting BLOB or binary columns (e.g., column_label.mimetype=content_type) |
column_label.filename | No | Column name that contains the filename used for extracting BLOB or binary columns (MIME type is inferred from the file extension) |
info.* | No | Additional JDBC connection properties (e.g., info.ssl=true). The key with info. removed is passed to the JDBC driver |
readInterval | No | Delay in milliseconds between processing each row. Default: 0 |
script_type | No | Script engine type. Default: groovy |
Script Configuration
Map SQL column names to index fields:
Available fields:
<column_name>- SQL query result columns (accessed directly by the column label name; no prefix such asdata.is used)
Note
Column names must match the column labels (aliases) in the SELECT clause. When using aggregate functions or expressions, assign an explicit alias with AS (e.g., COUNT(*) AS total).
Loading BLOB/Binary Data
Columns of type BLOB, CLOB, NCLOB, byte array, or binary stream are automatically passed through the content extraction process (the same extractor used for file crawling) and ingested as text. Array-type columns are converted to space-separated strings. NULL values become empty strings.
To correctly extract text from BLOB or binary streams, the data type (MIME type) must be determined. The following priority order is used:
column_label.mimetype=<column name>- Use the value of the specified column as the MIME typecolumn_label.filename=<column name>- Treat the value of the specified column as a filename and infer the MIME type from the file extensiondefault_mimetype- Default MIME type used when the above methods cannot determine the type
Example (extract BLOB in the file_data column using the MIME type from the content_type column):
SQL Query Design
Efficient Queries
Query performance is important when handling large amounts of data. SQL is sent to the database as-is (parameter binding is not performed):
Incremental Crawling
Methods to retrieve only updated records:
URL Generation
Generate document URLs in the script:
Multi-byte Character Support
When handling data with multi-byte characters such as Japanese:
MySQL
PostgreSQL
PostgreSQL uses UTF-8 by default. If needed:
Security
Protecting Database Credentials
Warning
Writing passwords directly in configuration files poses a security risk.
Recommended methods:
Use environment variables
Use Fess encryption features
Use read-only users
Principle of Least Privilege
Grant only the minimum necessary permissions to database users:
Usage Examples
Product Catalog Search
Parameters:
Script:
Knowledge Base Articles
Parameters:
Script:
Troubleshooting
JDBC Driver Not Found
Symptom: ClassNotFoundException or No suitable driver
Resolution:
Verify that the JDBC driver is placed in
lib/Verify that the driver class name is correct
Restart Fess
Connection Errors
Symptom: Connection refused or authentication errors
Check:
Is the database running?
Is the hostname and port correct?
Is the username and password correct?
Firewall settings
Query Errors
Symptom: SQLException or SQL syntax errors
Check:
Test the SQL query directly on the database
Verify that column names are correct
Verify that table names are correct
Reference Information
Data Store Connector Overview - Data Store Connector Overview
CSV Connector - CSV Connector
JSON Connector - JSON Connector
Data Store Crawling - Data Store Configuration Guide