--- /dev/null
+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 */;
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
// 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