MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / openConnection

Method openConnection

Utils/src/eu/the5zig/util/db/Database.java:44–61  ·  view source on GitHub ↗

Connects to a Database.

()

Source from the content-addressed store, hash-verified

42 * Connects to a Database.
43 */
44 protected synchronized Connection openConnection() throws NoConnectionException {
45 try {
46 try {
47 if (connection != null) {
48 closeConnection();
49 }
50 } catch (Exception ignored) {
51 }
52 getLogger().debug("Connecting to " + databaseConfiguration);
53 Class.forName(databaseConfiguration.getDriver());
54 Connection conn = databaseConfiguration.getConnection();
55 getLogger().debug("Connected to Database!");
56 connected = true;
57 return this.connection = conn;
58 } catch (Exception e) {
59 throw new NoConnectionException("Could not connect to " + databaseConfiguration, e);
60 }
61 }
62
63 public <T> SQLQuery<T> get(Class<T> entity) {
64 return new SQLQuery<T>(this, entity);

Callers 15

DatabaseMethod · 0.95
getConnectionMethod · 0.95
downloadFileMethod · 0.45
runMethod · 0.45
callMethod · 0.45
runMethod · 0.45
callMethod · 0.45
runMethod · 0.45
callMethod · 0.45
runMethod · 0.45
callMethod · 0.45
runMethod · 0.45

Calls 5

closeConnectionMethod · 0.95
getLoggerMethod · 0.95
forNameMethod · 0.80
getDriverMethod · 0.65
getConnectionMethod · 0.65

Tested by

no test coverage detected