Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use an in-memory Apache Derby database in Mule 4, configure MuleSoft’s Database Connector with a Derby connection whose database name is paired with subsubProtocol="memory" and enable creation with create="true". Initialize the tables your flow needs, and treat the data as temporary: it is held in the Mule JVM’s memory and is lost when that JVM shuts down or crashes.

Configure Derby memory mode in Mule 4

MuleSoft’s current Database Connector reference documents Derby connections, including a database name, a Derby subsub protocol, and a create option. In Mule 4, the configuration is a top-level <db:config> with a nested <db:derby-connection> element. A minimal shape is:

<db:config name="DerbyConfig">
  <db:derby-connection database="myDB" subsubProtocol="memory" create="true" />
</db:config>

Here, myDB is the database name, memory selects Derby’s in-memory mode, and create="true" lets Derby create the database if it does not already exist. The connector reference gives create a default of false, so set it explicitly when the application expects a new database. The reference identifies Database Connector 1.16; check the generated XML and accepted values against the connector and runtime versions in your project. MuleSoft Database Connector Reference.

The equivalent embedded JDBC URL pattern documented by Derby is jdbc:derby:memory:myDB;create=true. The colon after memory is required. Mule 4’s connector configuration expresses the database name and subsub protocol as separate settings; do not substitute an older URL-based sample for the current connector structure. Apache Derby: Using in-memory databases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Initialize the schema before the flow needs it

Creating the database does not create the tables or other schema objects your flow expects. Put schema creation in application initialization or run an idempotent migration step before processing begins. This makes startup reproducible and avoids a first request failing because a required table does not exist.

A historical MuleSoft flat-file integration tutorial illustrates opening an in-memory Derby database at startup with a Spring InitializingBean and creating tables. Use it as an illustration of the initialization principle, not as drop-in current Mule 4 code: its APIs and dependencies need to be checked for the target runtime. MuleSoft Blog tutorial.

Understand where the data lives and when it disappears

Apache Derby describes an in-memory database as residing entirely in main memory rather than the file system. The database is associated with the Derby instance and JVM that created it; another Derby instance using the same name does not share its contents. Derby removes the data when the JVM shuts down, crashes, or the machine shuts down. Derby’s in-memory database guide and the Derby 10.16 Developer’s Guide describe these lifecycle limits.

This makes memory mode useful for tests, development, and temporary or reproducible processing, but unsuitable as the sole store for records that must survive an application restart. Derby documents backup procedures for preserving an in-memory database for later use; for durable application data, use persistent database storage rather than relying on the transient instance.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Memory mode avoids disk storage for the database, but it is not a general performance guarantee. Database contents consume JVM memory, and Derby specifically calls out heap and page-cache sizing as considerations. Size the Mule JVM for the expected database workload and leave room for the rest of the application.

Choose in-memory Derby only when its scope fits

Consideration In-memory Derby Persistent database
Persistence and recovery Data is transient and disappears with the JVM; backup procedures are available if a copy must be preserved. Use when application data must remain available across JVM restarts.
Deployment scope Local to the Derby instance/JVM; independent JVMs do not share the same named in-memory database. Use a shared database service when multiple application instances need common data.
Resource profile Consumes JVM memory; heap and page-cache sizing matter. No universal speed advantage is established. Resource and performance characteristics depend on the selected database and deployment.
Lifecycle work Application startup must initialize schema, and cleanup should account for Derby’s drop behavior. Lifecycle and schema management depend on the persistent database and its operations.

Neither option is universally better. Choose based on whether data must be durable or shared, and whether the Mule JVM can safely carry the transient database’s memory use.

Drop the database deliberately when cleanup is needed

Derby supports dropping an in-memory database with a connection string such as jdbc:derby:memory:myDB;drop=true. Dropping also shuts down the database, so a preceding shutdown=true is optional. Derby documents that SQLState 08006 may be returned as the success signal for a drop; cleanup code should recognize that documented response rather than treating it automatically as an unsuccessful cleanup. If authentication and SQL authorization are both enabled, only the database owner can drop it. Apache Derby’s in-memory database guide.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Account for Mule 3 to Mule 4 configuration changes

Do not copy a Mule 3 Derby configuration into a Mule 4 application unchanged. MuleSoft’s migration guide shows <db:derby-config> becoming <db:config> containing <db:derby-connection>; the connection setting changes from url to database. Mule 4 also exposes create and subsubProtocol. MuleSoft Database Connector migration guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The applicable Mule runtime, Java version, and Derby driver artifact depend on the project’s deployment. The connector documentation establishes Derby support, but it does not establish one compatible version combination for every deployment. Verify the target project’s support matrix and dependency packaging before fixing those versions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.