Class DatabaseExecutor
java.lang.Object
ai.nervemind.app.executor.DatabaseExecutor
- All Implemented Interfaces:
NodeExecutor
Node executor for H2 database operations.
Executes SQL queries against an H2 database. Supports SELECT, INSERT, UPDATE, DELETE, and custom SQL operations with parameterized queries to prevent SQL injection.
Node Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
| jdbcUrl | String | Yes | H2 JDBC URL (e.g., jdbc:h2:mem:test or jdbc:h2:file:./data/mydb) |
| username | String | No | Database username (default: sa) |
| password | String | No | Database password (default: empty) |
| operation | String | No | Operation type: SELECT, INSERT, UPDATE, DELETE, DDL (default: SELECT) |
| query | String | Yes | SQL query with optional ? placeholders |
| parameters | String | No | Comma-separated values for ? placeholders |
| maxRows | Integer | No | Max rows to return for SELECT (default: 1000) |
| timeout | Integer | No | Query timeout in seconds (default: 30) |
Output Data
- rows - List of row maps (SELECT only)
- columns - List of column names (SELECT only)
- rowCount - Number of rows returned or affected
- success - Boolean indicating success
- executionTime - Query execution time in milliseconds
Security
Uses PreparedStatement with parameter bindings to prevent SQL
injection.
Only H2 JDBC URLs are accepted; other drivers are rejected.
- Since:
- 1.1.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
DatabaseExecutor
public DatabaseExecutor()Default constructor.
-
-
Method Details
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-