No Docker, no external processes, no native binaries. Add the dependency, write tests against real PostgreSQL SQL.
@MemgresTest class MyTest { @Test void insertAndQuery(Connection conn) throws SQLException { conn.createStatement().execute( "CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT NOT NULL)"); conn.createStatement().execute( "INSERT INTO users (name) VALUES ('Alice'), ('Bob')"); ResultSet rs = conn.createStatement().executeQuery( "SELECT name FROM users ORDER BY id"); rs.next(); assertEquals("Alice", rs.getString(1)); } }
JOINs, CTEs (recursive), window functions, GROUPING SETS, DISTINCT ON, LATERAL, subqueries, set operations.
Numeric, text, boolean, date/time, UUID, JSON/JSONB, arrays, enums, composites, ranges, geometric, network, XML.
String, math, date/time, JSON, array, full-text search, geometric, network, range, XML, and aggregate functions.
Stored procedures, DO blocks, control flow, exception handling, cursors, RAISE, GET DIAGNOSTICS, IN/OUT parameters.
Works with real pg_dump and pg_restore. Custom, directory, plain, and tar formats. Full round-trip data integrity.
BEGIN/COMMIT/ROLLBACK, savepoints, 3 isolation levels, SELECT FOR UPDATE/SHARE, SKIP LOCKED, deadlock detection.
Roles, GRANT/REVOKE, ALTER DEFAULT PRIVILEGES, row-level security policies.
80+ pg_catalog tables and 13+ information_schema views. Compatible with ORMs, Flyway, Liquibase, and introspection tools.
CREATE, DROP, ALTER DATABASE with full isolation. DROP WITH (FORCE), RENAME TO, auto-create on connect, configurable defaults.
Channel-based notifications with full transaction semantics. Deferred until COMMIT, discarded on ROLLBACK.
try (Memgres db = Memgres.builder().port(5432).build().start()) { System.out.println(db.getJdbcUrl()); // jdbc:postgresql://localhost:5432/memgres Thread.currentThread().join(); // keep running }
| Memgres | Testcontainers | H2 (PG mode) | embedded-postgres | |
|---|---|---|---|---|
| Docker required | No | Yes | No | No |
| Native binary | No | No | No | Downloads PG |
| Startup time | Milliseconds | Seconds | Milliseconds | Seconds |
| Wire protocol | Real PG v3 | Real PG | H2 protocol | Real PG |
| pg_dump compatible | Yes | Yes | No | Yes |
| SQL fidelity | PG 18 subset | Full PG | Partial | Full PG |
| System catalogs | 80+ tables | Full PG | Limited | Full PG |
| PL/pgSQL | Yes | Yes | No | Yes |
| CI-friendly | No deps | Needs Docker | No deps | Needs network |
<dependency> <groupId>com.memgres</groupId> <artifactId>memgres-junit5</artifactId> <version>0.1.0</version> <scope>test</scope> </dependency>