From 90d9401203d3d5d6b0f8c6f3e82170d1f190e5ae Mon Sep 17 00:00:00 2001 From: Maxime Duchene-Savard Date: Tue, 5 Aug 2025 23:58:46 -0400 Subject: [PATCH] first commit --- .gitignore | 38 +++++++++++++ .idea/.gitignore | 8 +++ .idea/encodings.xml | 7 +++ .idea/google-java-format.xml | 6 ++ .idea/misc.xml | 14 +++++ .idea/vcs.xml | 6 ++ pom.xml | 75 +++++++++++++++++++++++++ src/main/java/dev/mduchene/App.java | 17 ++++++ src/main/java/dev/mduchene/Db.java | 57 +++++++++++++++++++ src/test/java/dev/mduchene/AppTest.java | 13 +++++ 10 files changed, 241 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/encodings.xml create mode 100644 .idea/google-java-format.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 pom.xml create mode 100644 src/main/java/dev/mduchene/App.java create mode 100644 src/main/java/dev/mduchene/Db.java create mode 100644 src/test/java/dev/mduchene/AppTest.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..8b57f45 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7ace097 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a318e63 --- /dev/null +++ b/pom.xml @@ -0,0 +1,75 @@ + + 4.0.0 + + dev.mduchene + bolts + 1.0-SNAPSHOT + jar + + bolts + http://maven.apache.org + + + UTF-8 + + + + + + maven-compiler-plugin + 3.14.0 + + 21 + 21 + + + + + + + + + io.javalin + javalin + 6.7.0 + + + + + org.jooq + jooq + 3.20.5 + + + + + com.zaxxer + HikariCP + 7.0.0 + + + + + org.mariadb.jdbc + mariadb-java-client + 3.5.4 + + + + org.slf4j + slf4j-simple + 2.0.16 + + + + + + + org.junit.jupiter + junit-jupiter-api + 5.13.4 + test + + + diff --git a/src/main/java/dev/mduchene/App.java b/src/main/java/dev/mduchene/App.java new file mode 100644 index 0000000..9c2d32d --- /dev/null +++ b/src/main/java/dev/mduchene/App.java @@ -0,0 +1,17 @@ +package dev.mduchene; + +import io.javalin.Javalin; + +/** Hello world! */ +public class App { + public static void main(String[] args) { + Db db = + Db.Builder.create() + .url("jdbc:mariadb://localhost:3306/bolts") + .user("root") + .password("root") + .build(); + + var app = Javalin.create(cnf -> {}).get("/", ctx -> ctx.result("Hello World")).start(3001); + } +} diff --git a/src/main/java/dev/mduchene/Db.java b/src/main/java/dev/mduchene/Db.java new file mode 100644 index 0000000..d01f06f --- /dev/null +++ b/src/main/java/dev/mduchene/Db.java @@ -0,0 +1,57 @@ +package dev.mduchene; + +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +import java.sql.Connection; + +public class Db { + private HikariDataSource dataSource; + private Db() {} + + public static class Builder { + private String url; + private String user; + private String password; + + private Builder() {} + public static Builder create() { + return new Builder(); + } + + public Builder url(String url) { + this.url = url; + return this; + } + + public Builder user(String user) { + this.user = user; + return this; + } + + public Builder password(String password) { + this.password = password; + return this; + } + + public Db build() { + Db db = new Db(); + HikariConfig config = new HikariConfig(); + config.setJdbcUrl(url); + config.setUsername(user); + config.setPassword(password); + config.addDataSourceProperty("cachePrepStmts", "true"); + config.addDataSourceProperty("prepStmtCacheSize", "250"); + config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); + config.setMaximumPoolSize(64); + db.dataSource = new HikariDataSource(config); + return db; + } + } + + public Connection getConnection() throws Exception { + Connection connection = dataSource.getConnection(); + connection.setAutoCommit(false); + return connection; + } +} diff --git a/src/test/java/dev/mduchene/AppTest.java b/src/test/java/dev/mduchene/AppTest.java new file mode 100644 index 0000000..4012cdf --- /dev/null +++ b/src/test/java/dev/mduchene/AppTest.java @@ -0,0 +1,13 @@ +package dev.mduchene; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** Unit test for simple App. */ +public class AppTest { + @Test + public void testApp() { + assertTrue(true); + } +}