diff --git a/src/main/java/io/papermc/hangar/service/internal/projects/HomeProjectService.java b/src/main/java/io/papermc/hangar/service/internal/projects/HomeProjectService.java index 70223cee8..3e403e1b9 100644 --- a/src/main/java/io/papermc/hangar/service/internal/projects/HomeProjectService.java +++ b/src/main/java/io/papermc/hangar/service/internal/projects/HomeProjectService.java @@ -2,6 +2,8 @@ package io.papermc.hangar.service.internal.projects; import com.impossibl.postgres.jdbc.PGDataSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -11,12 +13,14 @@ import java.sql.SQLException; @Service public class HomeProjectService { + private static final Logger logger = LoggerFactory.getLogger(HomeProjectService.class); + private final String url; private final String username; private final String password; public HomeProjectService(@Value("${spring.datasource.url}") String url, @Value("${spring.datasource.username}") String username, @Value("${spring.datasource.password}") String password) { - this.url = url; + this.url = url.replace("postgresql", "pgsql"); this.username = username; this.password = password; } @@ -24,7 +28,7 @@ public class HomeProjectService { private Connection getConnection() throws SQLException { // force using pgjdbc-ng since that doesn't do dum begin queries that break cockroach PGDataSource ds = new PGDataSource(); - ds.setDatabaseUrl(url.replace("postgresql", "pgsql")); + ds.setDatabaseUrl(url); // ds.setSqlTrace(true); return ds.getConnection(username, password); } @@ -35,7 +39,11 @@ public class HomeProjectService { var stmt = con.createStatement()) { stmt.execute("REFRESH MATERIALIZED VIEW home_projects"); } catch (SQLException e) { - e.printStackTrace(); + if (e.getMessage().contains("Unsupported database URL")) { + logger.warn("Unsupported database URL: {}", url); + } else { + e.printStackTrace(); + } } } }