]> git.mxchange.org Git - jfinancials-swing.git/commitdiff
Some more cleanups + added initial SQL dump
authorRoland Haeder <roland@mxchange.org>
Fri, 31 Jul 2015 06:22:27 +0000 (08:22 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 31 Jul 2015 06:22:27 +0000 (08:22 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

Addressbook/install/tables.sql [new file with mode: 0644]
Addressbook/src/org/mxchange/addressbook/application/AddressbookApplication.java
Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java
Addressbook/src/org/mxchange/addressbook/contact/book/BookContact.java
Addressbook/src/org/mxchange/addressbook/database/backend/mysql/MySqlDatabaseBackend.java
Addressbook/src/org/mxchange/addressbook/manager/BaseManager.java

diff --git a/Addressbook/install/tables.sql b/Addressbook/install/tables.sql
new file mode 100644 (file)
index 0000000..a08e1de
--- /dev/null
@@ -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 */;
index 0898abe65f0e1963e98a78087f78d392ecfee9a8..e402ff4e460c1d017d291d877e3a432bed49a673 100644 (file)
@@ -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 {
 
index c6afdc9f97df72bcff8695762168dc5afdb34643..983bdeade41b4255460ef9347e2a6f7065e61077 100644 (file)
@@ -26,7 +26,6 @@ import org.mxchange.addressbook.client.Client;
  *
  * @author Roland Haeder
  * @version 0.0
- * @since 0.0
  */
 public class BaseContact extends BaseFrameworkSystem {
 
index 2acc7750cbba64d779b908b73a1dd4a786efff25..a9e8b8cb525b9d1b8edb0c01fae7ae8e64c470b4 100644 (file)
@@ -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 {
 
index 8b0ad9f32232fb19ffafb0ba200cb3ced58b9657..d863cb274230a8cdd72af3ae40271a828082530d 100644 (file)
@@ -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
index 41af226734e6b6a9eb8d9f32683c956976b56044..4dae2b1ea81f8ec006ee3d1ab6bfd6d8afb6131d 100644 (file)
@@ -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 {