Class DatabaseConnection

java.lang.Object
simu.dao.DatabaseConnection

public final class DatabaseConnection extends Object
Loads connection settings from src/main/resources/db.properties and provides JDBC Connections on demand. Lightweight by design — no pooling. Each get() opens a fresh connection. For an academic simulator this is more than enough; the application only persists once per run, at the end. If the properties file is missing or the database is unreachable, get() throws a SQLException so callers can decide whether to surface or swallow the error (we swallow it in the Controller so a DB outage does not crash the simulation).
  • Method Details

    • get

      public static Connection get() throws SQLException
      Open a brand-new connection. The caller is responsible for closing it.
      Throws:
      SQLException
    • ping

      public static boolean ping()
      Attempt a connection right now and close it. Useful for a startup health check.