Class Database
- java.lang.Object
-
- com.palmer.billingstatementgenerator.db.Database
-
public final class Database extends java.lang.ObjectManages the application's single file-based H2 database instance. The database file is stored in~/.wfh-billing/data.mv.dband persists across application launches. Schema and seed scripts are run only on first launch.Call
init()once at startup before any DAO is used.init()is idempotent — subsequent calls are no-ops.get()throwsIllegalStateExceptionif called beforeinit().
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.sql.DataSourceget()Returns the initializedDataSource.static voidinit()Initializes the file-based H2 database.
-
-
-
Method Detail
-
init
public static void init()
Initializes the file-based H2 database. On first launch, creates the database directory and runs the schema and seed scripts. Subsequent launches skip seeding. Safe to call multiple times; only the first call has any effect.
-
get
public static javax.sql.DataSource get()
Returns the initializedDataSource.- Returns:
- the application
DataSource - Throws:
java.lang.IllegalStateException- ifinit()has not been called
-
-