From 669ceb6256a7f4f06d95be7686bb965382037b84 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 29 Jul 2015 15:00:13 +0200 Subject: [PATCH] =?utf8?q?Implemented=20doShutdown()=20for=20MySQL=20backe?= =?utf8?q?nd=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../backend/mysql/MySqlDatabaseBackend.java | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java b/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java index 6a7b0094..900d5a89 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java @@ -57,19 +57,26 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas @Override public void connectToDatabase () throws SQLException { // Trace message - this.getLogger().trace("CALLED!"); + this.getLogger().trace("CALLED!"); //NOI18N // Generate connection string - String connect = String.format("jdbc:mysql://%s/%s", this.getProperty("org.mxchange.addressbook.database.mysql.host"), this.getProperty("org.mxchange.addressbook.database.mysql.dbname")); + String connect = String.format("jdbc:mysql://%s/%s", //NOI18N + this.getProperty("org.mxchange.addressbook.database.mysql.host"), //NOI18N + this.getProperty("org.mxchange.addressbook.database.mysql.dbname") //NOI18N + ); // Debug message - this.getLogger().debug(MessageFormat.format("Attempting to connect to {0} ...", connect)); + this.getLogger().debug(MessageFormat.format("Attempting to connect to {0} ...", connect)); //NOI18N // Now get a connection instance back - this.connection = DriverManager.getConnection(connect, this.getProperty("org.mxchange.addressbook.database.mysql.login"), this.getProperty("org.mxchange.addressbook.database.mysql.password")); + this.connection = DriverManager.getConnection( + connect, + this.getProperty("org.mxchange.addressbook.database.mysql.login"), //NOI18N + this.getProperty("org.mxchange.addressbook.database.mysql.password") //NOI18N + ); // Trace message - this.getLogger().trace("EXIT!"); + this.getLogger().trace("EXIT!"); //NOI18N } @Override @@ -79,7 +86,15 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas @Override public void doShutdown () { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + // This should not happen: + assert(this.connection == null) : "connection is null"; + + try { + // Close down database connection + this.connection.close(); + } catch (final SQLException ex) { + this.abortProgramWithException(ex); + } } @Override -- 2.39.5