H2 API¶
The H2 API provides a set of operations for interacting with H2 databases, allowing users to connect, execute queries, create tables, insert records, fetch data, update tables, delete data, and manage database connections.
Why Integrate H2 Database with EasyTask?¶
Integrating H2 Database with EasyTask enables you to automate JDBC database operations for development and testing workflows. This integration allows you to:
- Automate Database Operations: Execute SQL queries, create tables, insert records, and manage data programmatically as part of your EasyTask workflows.
- Streamline Testing Pipelines: Leverage H2's lightweight in-memory database capabilities to automate setup and teardown of test databases through EasyTask orchestration.
- Flexible Data Management: Fetch, update, and delete data with conditional queries, enabling sophisticated data processing and ETL workflows.
Required Values in Vault¶
{
"secret": {
"class_path": "/path/to/the/jar/file.jar",
"database_url": "jdbc:h2:~/<db-name>",
"jdbc_driver_class": "org.h2.Driver",
"password": "xxxx",
"username": "xxxx"
}
}
Example Usage¶
curl -X POST http://localhost:8008/run-integration \
-H "Content-Type: application/json" \
-d '{
"is_credentials": {
"userid": "test",
"passwd": "test123"
},
"integration": "h2",
"uuid": "ae0e8ba9-423a-410e-bba5-e1933ff868c5",
"init": {
"vault_path_key": "h2/secret"
},
"action": [
{
"connect": {}
}
]
}'
Functions¶
connect¶
connect: This function establishes a connection to the H2 database.
execute¶
execute: This function executes a SQL query on the H2 database.
create_table¶
create_table: This function creates a new table in the H2 database.
| Input Parameter | Type | Description | Mandatory |
|---|---|---|---|
| table_name | str | Name of the table to create | yes |
| cols | list | List of column definitions | yes |
| Output Parameter | Type | Description |
|---|---|---|
| response | bool | True if the table was created successfully |
insert_record¶
insert_record: This function inserts records into a table in the H2 database.
| Input Parameter | Type | Description | Mandatory |
|---|---|---|---|
| table_name | str | Name of the table to insert into | yes |
| records | list | List of records to insert | yes |
| Output Parameter | Type | Description |
|---|---|---|
| response | bool | True if the records were inserted successfully |
fetch_all¶
fetch_all: This function retrieves all records from a table in the H2 database.
fetch_data¶
fetch_data: This function retrieves records from a table in the H2 database based on specified conditions.
| Input Parameter | Type | Description | Mandatory |
|---|---|---|---|
| table_name | str | Name of the table to fetch from | yes |
| where | list | List of conditions for the WHERE clause | yes |
| Output Parameter | Type | Description |
|---|---|---|
| response | list | List of records matching the conditions |
update_table¶
update_table: This function updates records in a table in the H2 database.
| Input Parameter | Type | Description | Mandatory |
|---|---|---|---|
| table_name | str | Name of the table to update | yes |
| upd | list | List of update statements | yes |
| where | list | List of conditions for the WHERE clause | yes |
| Output Parameter | Type | Description |
|---|---|---|
| response | bool | True if the update was successful |
delete_data¶
delete_data: This function deletes records from a table in the H2 database.
drop_table¶
drop_table: This function drops (deletes) a table from the H2 database.
disconnect¶
disconnect: This function closes the connection to the H2 database.
Frequently Asked Questions¶
How do I configure H2 Database credentials in EasyTask?¶
Use the EasyTask vault system to securely store your H2 Database connection credentials. Navigate to the integration configuration page and add your JDBC URL, driver class, JAR path, username, and password under a vault key like h2/secret.
Can I use H2 Database with both EasyTask Cloud and On-Premises?¶
Yes, H2 Database works seamlessly with both EasyTask Cloud and On-Premises deployments. The configuration process is identical.
How do I troubleshoot H2 Database connection issues?¶
Check the integration server logs in EasyTask for detailed error messages. Verify your JDBC URL, driver class path, and credentials in the vault, ensure the H2 JAR file is accessible, and test connectivity using the built-in connection test feature.