Class DatabaseConnection
java.lang.Object
simu.dao.DatabaseConnection
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 Summary
Modifier and TypeMethodDescriptionstatic Connectionget()Open a brand-new connection.static booleanping()Attempt a connection right now and close it.
-
Method Details
-
get
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.
-