Skip to content

Using multiple declarations of jdbc:embedded-database creates only one H2 instance per JVM [SPR-8920] #13560

@spring-projects-issues

Description

@spring-projects-issues

Etienne Studer opened SPR-8920 and commented

When using the jdbc:embedded-database element, Spring will use the same database name for each embedded database instance that it tries to create. As a consequence of using the same database name, all connections go against the same embedded H2 instance (and thus the data is shared) -> this causes troubles if multiple (and unrelated) application contexts are running at the same time or if more than one H2 instance with a separate datastore is needed in one application context.

See http://www.h2database.com/html/features.html#in_memory_databases for details.

Suggested fix: Provide a databaseName attribute on the jdbc:embedded-database element. This way, the developer can control the scope/visibility of the H2 instances.


Affects: 3.0.5

Issue Links:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions