From fde437c9f0d69d74d285699a728f1ebcc7dbfd31 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 31 Jul 2015 08:22:27 +0200 Subject: [PATCH] =?utf8?q?Some=20more=20cleanups=20+=20added=20initial=20S?= =?utf8?q?QL=20dump=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Addressbook/install/tables.sql | 42 +++++++++++++++++++ .../application/AddressbookApplication.java | 1 - .../addressbook/contact/BaseContact.java | 1 - .../addressbook/contact/book/BookContact.java | 1 - .../backend/mysql/MySqlDatabaseBackend.java | 8 ++-- .../addressbook/manager/BaseManager.java | 1 - 6 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 Addressbook/install/tables.sql diff --git a/Addressbook/install/tables.sql b/Addressbook/install/tables.sql new file mode 100644 index 0000000..a08e1de --- /dev/null +++ b/Addressbook/install/tables.sql @@ -0,0 +1,42 @@ +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + + +DROP TABLE IF EXISTS `contacts`; +CREATE TABLE IF NOT EXISTS `contacts` ( +`id` bigint(20) unsigned NOT NULL COMMENT 'Primary key', + `own_contact` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Whether own contact', + `gender` varchar(10) NOT NULL DEFAULT 'UNKNOWN' COMMENT 'Gender', + `surname` varchar(100) NOT NULL COMMENT 'Surname', + `family_name` varchar(100) NOT NULL COMMENT 'Family name', + `company_name` varchar(255) DEFAULT NULL COMMENT 'Company name', + `street` varchar(255) DEFAULT NULL COMMENT 'Street name', + `house_number` smallint(5) unsigned DEFAULT NULL COMMENT 'House number', + `city` varchar(100) DEFAULT NULL COMMENT 'City name', + `zip_code` smallint(5) unsigned DEFAULT NULL COMMENT 'ZIP code', + `country_code` char(2) DEFAULT NULL COMMENT 'Country code', + `phone_number` varchar(100) DEFAULT NULL COMMENT 'Phone number', + `cellphone_number` varchar(100) DEFAULT NULL COMMENT 'Cellphone number', + `fax_number` varchar(100) DEFAULT NULL COMMENT 'Fax number', + `email_address` varchar(100) DEFAULT NULL COMMENT 'Email addres', + `birthday` date DEFAULT NULL COMMENT 'Birth day', + `comment` tinytext NOT NULL COMMENT 'Comment', + `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Entry created', + `updated` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Contacts data' AUTO_INCREMENT=1 ; + + +ALTER TABLE `contacts` + ADD PRIMARY KEY (`id`); + + +ALTER TABLE `contacts` +MODIFY `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key'; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java b/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java index 0898abe..e402ff4 100644 --- a/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java +++ b/Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java @@ -70,7 +70,6 @@ import org.mxchange.addressbook.manager.application.ApplicationManager; * * @author Roland Haeder * @version 0.0 - * @since 0.0 */ public class AddressbookApplication extends BaseFrameworkSystem implements Application { diff --git a/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java b/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java index c6afdc9..983bdea 100644 --- a/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java +++ b/Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java @@ -26,7 +26,6 @@ import org.mxchange.addressbook.client.Client; * * @author Roland Haeder * @version 0.0 - * @since 0.0 */ public class BaseContact extends BaseFrameworkSystem { diff --git a/Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java b/Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java index 2acc775..a9e8b8c 100644 --- a/Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java +++ b/Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java @@ -25,7 +25,6 @@ import org.mxchange.addressbook.database.storage.csv.StoreableCsv; * * @author Roland Haeder * @version 0.0 - * @since 0.0 */ public class BookContact extends BaseContact implements Contact, StoreableCsv { 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 8b0ad9f..d863cb2 100644 --- a/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java +++ b/Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java @@ -101,7 +101,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas this.getLogger().debug("Connection is up, preparing some statements ..."); //NOI18N // Here, the connection is established, so prepare some statements - this.totalRowCount = MySqlDatabaseBackend.connection.prepareStatement("SELECT COUNT(`id`) AS `cnt` FROM ? LIMIT 1"); //NOI18N + this.totalRowCount = MySqlDatabaseBackend.connection.prepareStatement(String.format("SELECT COUNT(`id`) AS `cnt` FROM `%s` LIMIT 1", this.getTableName())); //NOI18N // Trace message this.getLogger().trace("EXIT!"); //NOI18N @@ -122,18 +122,16 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas // Close down database connection MySqlDatabaseBackend.connection.close(); } catch (final SQLException ex) { + // Something happened during close() this.abortProgramWithException(ex); } } @Override - public int getTotalCount () throws SQLException{ + public int getTotalCount () throws SQLException { // Nothing counted by default int count = 0; - // Set table name - this.totalRowCount.setString(1, this.getTableName()); - // Prepared statements are cool ... if (this.totalRowCount.execute()) { // Did fully work, so get result set diff --git a/Addressbook/src/org/mxchange/addressbook/manager/BaseManager.java b/Addressbook/src/org/mxchange/addressbook/manager/BaseManager.java index 41af226..4dae2b1 100644 --- a/Addressbook/src/org/mxchange/addressbook/manager/BaseManager.java +++ b/Addressbook/src/org/mxchange/addressbook/manager/BaseManager.java @@ -23,7 +23,6 @@ import org.mxchange.addressbook.BaseFrameworkSystem; * * @author Roland Haeder * @version 0.0 - * @since 0.0 */ public class BaseManager extends BaseFrameworkSystem implements Manageable { -- 2.39.5