Implements database, adds profiles

This commit is contained in:
2025-10-01 22:23:00 +02:00
parent b2571c191f
commit d2da811868
86 changed files with 17323 additions and 483 deletions

View File

@@ -0,0 +1,4 @@
package ch.gtache.fro.h2;
public class H2ConfigurationManager {
}

View File

@@ -0,0 +1,38 @@
package ch.gtache.fro.modules.h2;
import dagger.Module;
import dagger.Provides;
import jakarta.inject.Singleton;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/**
* Dagger module for H2
*/
@Module
public final class H2Module {
private H2Module() {
}
@Provides
@Singleton
static Connection providesJdbcConnection() {
try {
final var connection = DriverManager.getConnection("jdbc:h2:mem:");
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
connection.close();
} catch (final SQLException e) {
throw new RuntimeException("Error closing H2 connection", e);
}
}));
return connection;
} catch (final SQLException e) {
throw new RuntimeException("Error connecting to H2", e);
}
}
}

View File

@@ -0,0 +1,8 @@
/**
* H2 module for the FRO application
*/
module ch.gtache.fro.h2 {
requires transitive ch.gtache.fro.database;
exports ch.gtache.fro.h2;
exports ch.gtache.fro.modules.h2;
}