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

29
h2/pom.xml Normal file
View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ch.gtache.fro</groupId>
<artifactId>fro</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>fro-h2</artifactId>
<properties>
<h2.version>2.4.240</h2.version>
</properties>
<dependencies>
<dependency>
<groupId>ch.gtache.fro</groupId>
<artifactId>fro-database</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
</dependencies>
</project>

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;
}