Choosing a database for HAPI FHIR

Choosing the database behind a HAPI FHIR JPA server decides your supported production options, your licensing bill and your operating workload. This page compares PostgreSQL, SQL Server and Oracle and explains what to confirm before you commit.

On this page

Choosing a database for HAPI FHIR starts with what the starter supports

For the HAPI FHIR JPA server starter, the production database choices are PostgreSQL and Microsoft SQL Server. The starter defaults to an embedded H2 database, which suits development and testing only, and it does not support MySQL. If your organization runs MariaDB or MySQL, that is a decision to revisit before the build starts, not after. Oracle is a different case: it is covered in its own sibling topic, so the comparison here stays on what the starter ships with.

HAPI FHIR reaches the database through the JPA API rather than through database-specific code, which is why the server can run on more than one engine. The JPA layer does not remove the differences, though. Each engine needs its own dialect setting, JDBC driver and migration behavior, and the starter's supported set is the one your team can expect the project to test against. Confirm the exact supported versions for your chosen HAPI FHIR release in the HAPI FHIR JPA server introduction before you commit.

The starter can be deployed as the hapiproject/hapi Docker image, with Docker Compose, with Spring Boot, as a WAR on Tomcat, Jetty or Wildfly, or on Kubernetes with a Helm chart. The database choice constrains each of these paths, and it also sets who you need: a PostgreSQL shop may already have DBAs and backup tooling, while a Microsoft shop may already hold SQL Server licenses. Ask your database team which engine they can operate with existing skills, and write that answer into the scope before the platform is selected.

How PostgreSQL, SQL Server and Oracle compare for a FHIR workload

PostgreSQL is one of the two databases the JPA server starter supports for production, and it is the option most teams reach for when they want an open-source stack from end to end. It carries no database license fee of its own, so the cost questions shift to who operates the database, how backups and recovery are run, and whether you choose a self-run instance or a managed service in your own cloud account. Dedicated sibling guidance covers the HAPI dialect, connection pools and collation, the PostgreSQL-specific indexes added in 7.0, and the routine work of backups, vacuum and replication for a FHIR workload.

  • Operational ownership: Someone must own vacuum tuning, minor and major version upgrades, failover and point-in-time recovery, whether that is a database team or a managed service.
  • Recovery testing: Clinical data makes restore drills more important than backup job status, so confirm how a standby is promoted and how a restore is verified.
  • Collation and pool settings: Collation and connection pool sizing affect search behavior and load, so settle them in the build plan rather than during a later tuning pass.
  • Hosting model: A self-run virtual machine, a Kubernetes operator or a managed service each divides responsibility differently between your team and the provider.

PostgreSQL fits organizations that already run it for other systems and teams with open-source database skills in place. Before committing, confirm with the HAPI FHIR documentation for your target version which PostgreSQL releases are supported.

Database options and when each fits

This table compares the databases people most often consider behind the HAPI FHIR JPA server, with starter status, fit, licensing questions and the operating skills each one asks of your team. Read the status column first, since it decides whether an option is a candidate at all, then use the other columns to weigh the remaining choices against your licensing position and existing database skills.

DatabaseStarter statusWhen it fitsLicensing and skills to confirm
PostgreSQLSupported for production in the starterOpen-source estate with in-house PostgreSQL skills and a team that can run HA, backups and upgradesNo license fee for the database itself; confirm HA tooling, support contract and who owns major version upgrades
Microsoft SQL Server and Azure SQLSupported for production in the starterOrganizations already standardized on SQL Server with DBAs and Windows or Azure operations experienceConfirm edition, core licensing and whether Azure SQL managed service terms fit your data residency rules
Oracle DatabaseSupported by HAPI FHIR with its own dialect and driver setup; confirm against the current documentationSites with established Oracle licensing, DBAs and procurement agreements that already cover the required editionsConfirm edition and option licensing, Standard edition index locking during upgrades and the JDBC driver terms
H2 (embedded)Default for the starter, for development onlyLocal testing, demos and proof-of-concept work with no patient dataNot a production option; plan the move to a production database before any real data is loaded
MySQL and MariaDBNot supported by the starterNot a fit for the HAPI FHIR JPA starter as shippedDo not plan a production deployment on these without a confirmed, supported path from the project
CockroachDBExperimental; not covered here as a production optionOnly for teams running a proof of concept who accept experimental statusConfirm current status and support with the HAPI FHIR project before any planning or budget work

Why MySQL, MariaDB and CockroachDB are not production choices here

Three database engines drop out of the shortlist for a HAPI FHIR JPA server, and the embedded default is never a production option. Each exclusion rests on a different point: what the starter supports, what the project supports for production, and what its experimental status means for a clinical data store.

MySQL is not supported by the starter

The hapi-fhir-jpaserver-starter does not support MySQL, so a MySQL instance is not a path you can take with the starter as shipped. Before any planning starts, confirm that your chosen deployment method (Docker image, Spring Boot, WAR or Helm chart) uses a supported database driver and dialect. Teams already standardized on MySQL should weigh that choice against PostgreSQL or Microsoft SQL Server before a build begins, since switching later means a data move through FHIR exports.

Starter repository

MariaDB is not a production option

MariaDB is not a supported production choice for the starter, even though it is a MySQL-family database. Treat MariaDB as out of scope for a production FHIR store and do not assume that a compatible driver means a supported configuration. If your hosting standard is MariaDB, raise it early with the platform team and compare the supported options on their operational merits.

CockroachDB is experimental

CockroachDB is experimental for this server and should not be chosen for a production FHIR store unless the HAPI FHIR project confirms support for your version and workload. Distributed SQL can look attractive for scale, but the consequences fall on schema migrations, search behavior and recovery procedures. Ask the project in writing for its current status before you consider it, and keep the decision in your architecture record.

H2 is for development only

The starter defaults to an embedded H2 database, which suits local testing and demonstrations but is not a production choice. An H2 deployment has no separate database server to back up, replicate or tune, so it cannot carry clinical data. Plan the move to PostgreSQL or Microsoft SQL Server as part of the first build, and include the test changes that the switch requires.

Production needs a supported engine

The supported production databases for the starter are PostgreSQL and Microsoft SQL Server, so the practical shortlist starts there. Oracle is covered separately because it is not a starter default, and it needs its own dialect and driver work. The check that matters is whether your version of the server and its migrator support the engine you pick, which you should confirm against the release notes for your target version.

HAPI FHIR versions

Steps to select and validate a database before the build

This sequence turns the database question into a written decision backed by a version check, a supported-database check, a sized workload and a trial run. The output is a recorded choice the client's security, compliance and platform teams can review before any production build starts.

  1. Confirm the HAPI FHIR version and JDK requirement

    Choose the HAPI FHIR release line the server will run, then confirm the Java runtime it needs. HAPI FHIR 8.2.0 requires JDK 17, and the release notes for the chosen version should be checked for any later change. The platform team confirms the JDK can be provided in the client's infrastructure and that the version is current enough for the planned support window. Done when the version, JDK and upgrade path are written into the decision record.

  2. Confirm supported databases for the release

    Check the JPA server starter for the chosen release and confirm which databases it supports for production. The starter supports PostgreSQL and Microsoft SQL Server for production, defaults to an embedded H2 database for development, and does not support MySQL. Oracle and CockroachDB need to be checked against the release notes and documentation for the exact version, because support status can differ. Done when each candidate is marked supported, unsupported or experimental for that version.

  3. Size the workload and partitioning needs

    The architect estimates expected resource counts, write rates, search patterns, history retention and backup window with the client's data owners. Decide whether multitenancy, regional grouping or separate data sources need partitioning, since partitioning places each resource in a partition. The outputs are a rough storage estimate, a growth assumption and a clear yes or no on partition mode, which affects schema setup later. Done when the sizing assumptions are signed off by the client's technical owner.

  4. Pick the database and edition

    Compare the shortlisted databases on licensing terms, the operations skills the client already has, backup and high availability tooling in their environment, and the cost components listed in the quote request. Licensing for Oracle and SQL Server editions differs, and PostgreSQL carries no license fee, but operations staffing and hosting still cost money. Confirm with each vendor and the client's procurement team which edition covers the features needed. Done when one database and edition is chosen with a written rationale.

  5. Provision the database in client infrastructure

    Deploy the chosen database in the client's cloud account, data center or air-gapped network, with network segmentation, encryption at rest and in transit, and separate credentials for the application and the migrator. The DBA or platform engineer records the version, collation settings where the database requires them, and backup configuration. Done when the instance is reachable only from the intended application subnet and a restore from a test backup has been attempted.

  6. Run a trial migrator and load test

    Run the HAPI FHIR schema migrator against the provisioned database in a non-production environment, then load representative FHIR data and run the expected search and write patterns. Record migration time, any errors, index behavior, query latency and resource use on the database. Compare results against the sizing assumptions from earlier. Done when the migrator completes cleanly and the load results are documented against agreed acceptance criteria.

  7. Record the database decision

    Write a decision record that names the HAPI FHIR version, JDK, database, edition, partition approach, sizing assumptions, trial results and open risks. The record should list who approved the choice and which items the client must confirm with the database vendor or in their own environment. Store it with the architecture documents so security, compliance and future upgrade teams can review it. Done when the record is approved and linked from the project plan.

How the database decision flows into the build

The diagram starts with the requirements that actually decide the database: existing team skills, whether the licensing and hosting teams will approve a commercial engine, and whether partitioning is planned. Those answers lead to one of three supported choices for production, PostgreSQL, SQL Server or Oracle, while MySQL, MariaDB and CockroachDB sit in an excluded group. The chosen engine then passes through a validation stage (the JPA starter run against a representative load and a restore test) before the production build begins. Check that the requirement answers are written down before the choice is made.

Requirements lead to one supported engine, then validation before the production build.

What drives licensing and operations cost for each database

The HAPI FHIR software itself carries no license fee: it is released under the Apache Software License 2.0, so the money in a database decision goes to the database engine, its support terms and the people who run it. Each option has a different cost shape. PostgreSQL is open source, so its direct license cost is usually zero, and cost comes from support subscriptions if you buy them, from hosting, and from staff time. SQL Server and Oracle Database are commercial products, so the license terms, edition and core or processor counts you choose set a large part of the cost, and Oracle's Standard edition versus Enterprise edition decision directly affects what high availability and partitioning features you can use. Confirm current edition names, licensing metrics and support terms directly with Microsoft and Oracle, and check whether your cloud provider's managed service changes the licensing picture.

Separate one-time setup from recurring operations when you compare quotes. One-time work includes environment design, the initial schema migration, connection pool and collation tuning, load testing and the first backup and restore drill. Recurring costs include database licenses or support renewals, high availability nodes (replicas, standby instances or clustered hosts), backup storage and retention, monitoring, patching, major version upgrades and the DBA or platform engineer hours they consume. High availability and replication roughly double the number of database instances you pay to host and patch, which is often the largest recurring line item for a clinical workload. Storage cost grows with resource history, search indexes and retention, so ask how the chosen configuration affects table growth over the life of the system.

Ask any quote to itemize four things: the license metric and edition, the number of instances including standbys and non-production environments, the support level and response terms, and who performs backups, restores, upgrades and vendor patching. Ask the implementer to state which tasks are included in fixed scope and which are billed as additional work, such as a later major database upgrade or a schema migration on a grown dataset. Also ask what you would pay if you change database engines later, because moving an established FHIR dataset is a separate project. These questions make the comparison concrete, because two quotes for the same HAPI FHIR server can differ mainly in their licensing assumptions and in who carries day-two operations.

Security and operational considerations for the database layer

The database behind a HAPI FHIR JPA server holds every resource, version and search index, so it inherits the same privacy and availability obligations as the FHIR API. The cards below cover the controls the operator must add around the database, the upgrade-time risks specific to Oracle Standard edition, and the collation settings that decide whether indexes are used at all.

No single security layer

HAPI FHIR does not ship one security layer. It provides building blocks such as authentication interceptors, the AuthorizationInterceptor, consent and search narrowing interceptors and CORS support, and the operator must assemble them. The database sits behind all of this, so direct database access bypasses every FHIR-level control. Confirm that only the application server can reach the database port, that no analyst tooling connects with write rights, and that network policy is documented alongside the FHIR access design.

HAPI FHIR security docs

Database access and credentials

The JPA server connects with a database account whose privileges depend on the migrator and runtime roles you define. Give the runtime account only the rights the server needs, keep migrator credentials separate and short-lived, and store both in a secrets manager rather than in plain configuration files. Ask your database team how credential rotation will be done without restarting the entire FHIR tier, and who holds the keys for the database host itself.

Encryption and backups

Encryption at rest and in transit are properties of the database platform and the network, not of HAPI FHIR. Confirm TLS on the JDBC connection, disk or volume encryption on the database host, and key management for backup copies. Backups of the HFJ tables contain full patient records, so they need the same classification and retention rules as the live database. Test restores into a separate environment on a schedule, since a backup that has never been restored is not yet evidence.

Upgrade-time schema migration and locking

HAPI FHIR upgrades run schema migrations, and on Oracle Standard edition index changes can lock tables while they run. Plan the migration window, rehearse the upgrade on a copy of production data, and check the Java requirement for the target release. Confirm with your Oracle DBA how long index rebuilds will hold locks on your data volume before you commit to a maintenance window, and keep a tested rollback path for the schema.

Collation and Unicode settings

On Microsoft SQL Server, the JDBC Unicode setting and the database collation determine whether string indexes are used. A mismatch can cause full table scans that look like a performance fault but are really a configuration fault. Case-sensitive collation also changes how IDs match, which matters when migrating data. Set these values before loading data, verify them with an explain plan on a representative search, and record them in your configuration baseline so later changes are reviewed.

Audit logging through BALP and added controls

BALP, the Basic Audit Log Pattern, records who accessed which FHIR resources, but it is only one control. Database-level auditing, such as statement or login auditing offered by your database platform, records access that bypasses the FHIR API. Decide where audit records are stored, how long they are kept and who can read them, and confirm that audit storage is separate from the database being audited. Ask your compliance team which events they need to evidence before choosing the database platform.

Security building blocks

Questions buyers ask before choosing a database for HAPI FHIR

Which database should we choose for a production HAPI FHIR server?

For most production deployments, the choice is between PostgreSQL and Microsoft SQL Server, because the JPA server starter documents those two for production use. The deciding factors are usually the database platform your organization already operates, the licensing position for each engine, and which engine your team can back up, restore, patch and upgrade within your recovery targets. PostgreSQL has no license fee for the database itself. SQL Server licensing depends on edition and core count. Oracle can be used, but it has its own dialect and driver setup, so confirm its current status for your HAPI release before you plan around it. Check the starter documentation for the supported list that applies to the version you intend to run.

Does MySQL or MariaDB work with HAPI FHIR?

No, MySQL is not a supported database for the HAPI FHIR JPA server starter. The starter's documentation states that it does not support MySQL, and MariaDB should not be planned as a production backend either. Teams that already run MySQL or MariaDB face a platform decision: either add a supported engine such as PostgreSQL or SQL Server to their estate, or accept a configuration that the HAPI project does not support and that you would have to validate and maintain yourselves. The second path adds ongoing risk at every upgrade. Confirm the current position in the project documentation before any architecture decision, because support statements can change between releases.

Is CockroachDB safe to use with HAPI FHIR?

Treat CockroachDB as experimental for HAPI FHIR and do not place production patient data on it without a documented decision from the HAPI project and your own testing. The concern is less about basic connectivity and more about whether the combination is supported end to end. The areas to test are transaction behavior under the JPA layer, schema migration with the migrator, search and bulk load performance, backup and restore tooling, and upgrades between HAPI releases. Ask the HAPI project for the current status of CockroachDB, and ask CockroachDB which driver and version they support for the combination you plan to run. If the answers are not written down, your organization carries the full support burden.

What drives the licensing cost of a HAPI FHIR database?

The HAPI FHIR server is licensed under Apache Software License 2.0, and PostgreSQL is open source, so licensing cost comes mainly from commercial database engines and any support contracts you add. The main drivers are the edition you choose, how the engine is licensed (for example by cores or by user), and which environments need a license: production, disaster recovery, test and staging. Ask whether standby or replica instances count toward the license, and whether cloud marketplace terms differ from on-premises terms. Recurring costs usually include annual support renewals, while the license purchase itself is one-time. If you also want commercial support for HAPI FHIR, the project's README points to Smile CDR, and that is a separate cost to quote. Get every term in writing from each vendor.

How long do database selection and validation take, and what do we provide?

The duration depends on the number of database options under review, the data volumes you expect, and how much validation your compliance and security teams require, so no fixed figure applies. The work usually covers requirements for data volume, recovery objectives and hosting, a load test with representative FHIR data, an upgrade rehearsal, a backup and restore test, and a review of the security settings for the chosen engine. On your side, you will need access to the target infrastructure, named database and operations contacts, rules for generating or supplying test data, and a decision maker who can accept the licensing terms. A quote follows from the written scope, so the scope is the best place to set the timeline.

Can our team choose and run the database without a partner?

Yes, many teams can make this choice and run the result themselves if they already operate the engine and the Java services. The work that tends to be underestimated is operational: backups with tested restores, point-in-time recovery, connection and resource tuning, and planning each HAPI FHIR upgrade against its Java requirements. For example, HAPI FHIR 8.2.0 requires JDK 17, so the runtime changes you make for one release can affect the next. A partner adds most value where your team lacks recent experience with the engine, has no time for a validation cycle, or needs an independent record of the decision for an assessor. Assess your skills against the operational list before deciding.

What does a DeployOpen engagement cover for database selection?

DeployOpen plans, implements, hardens, backs up, upgrades, documents and supports self-hosted open-source platforms inside your own infrastructure, including your cloud accounts, data centers or air-gapped networks. For database selection, a typical written scope covers comparing the supported engines against your requirements, configuring the JPA server starter for the chosen engine, testing backup and restore, and documenting the decision and its operating procedures. Most engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts. Ongoing support, upgrades and continuous testing are available as retainers. DeployOpen does not publish a price list, so the written scope determines the quote. DeployOpen does not issue audit reports or certifications, so any assessor evidence comes from your auditors.

What should we confirm with database and HAPI vendors before deciding?

Confirm five things in writing before you commit: the database versions and editions the HAPI project supports for the release you plan to run, the JDBC driver version each vendor supports, the license terms for each environment and any standby instances, the vendor's support windows and escalation path, and the backup and restore tooling that works with your recovery targets. Also confirm the database requirements of any HAPI feature you intend to use, such as partitioning or MDM, because those features can change schema and indexing needs. Version and support statements change between releases, so check the HAPI FHIR versions page on the day you decide, not only at the start of the project.

How DeployOpen works on this

DeployOpen starts by confirming which database your HAPI FHIR JPA server must run on, using your hosting, licensing and operations constraints. We then build, test and document the chosen database configuration inside infrastructure you control, so your own teams can review and run it.

How we scope

  • Written scope lists the databases compared, the HAPI FHIR version and the hosting environment.
  • Scope records licensing terms, existing database skills and support contracts your organization already holds.
  • Fixed-scope engagements agree deliverables and timelines in writing before any build work starts.

How we build

  • Build a proof-of-concept JPA server on the shortlisted database and run representative FHIR loads.
  • Test the starter's database settings, connection pools, schema migration and backup restore on that database.
  • Record the database choice, its licensing position and its operating model in a decision document.

How we hand over

  • Hand over deployment configuration, database settings and migration steps as versioned files your team owns.
  • Walk your database administrators and platform engineers through backup, restore and upgrade procedures.
  • Deliver a runbook covering operations tasks, monitoring points and the items to confirm with each vendor.

How we support

  • Ongoing support, upgrades and continuous testing for the database layer are available as retainers.
  • Retainer work can cover planned HAPI FHIR version upgrades and database engine upgrades on your schedule.
  • Support scope and response arrangements are set out in writing with your engagement, not assumed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.