@Override
public int getTotalCount () throws SQLException {
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("tableName={0} - CALLED!", this.getTableName())); //NOI18N
+
// Nothing counted by default
int count = 0;
// Get integer from 'cnt' alias (see statement)
count = set.getInt("cnt"); //NOI18N
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("count={0}", count)); //NOI18N
+
// Go back to beginning
set.beforeFirst();
+ } else {
+ // Empty result
+ this.getLogger().warn(MessageFormat.format("COUNT() query didn't return any result on table {0}.", this.getTableName())); //NOI18N
}
+ // Trace message
+ this.getLogger().trace(MessageFormat.format("count={0} - EXIT!", count)); //NOI18N
+
// Return result
return count;
}
* @return Total contact count
*/
@Override
- public int getContactsCount () {
+ public int getContactsCount () throws SQLException {
// And deligate to backend
return this.getBackend().getTotalCount(); //NOI18N
}
* @return Whether own contact is found
*/
@Override
- public boolean isOwnContactFound () {
+ public boolean isOwnContactFound () throws SQLException {
// Deligate this call to backend
return this.getBackend().isRowFound(ContactDatabaseConstants.COLUMN_NAME_OWN_CONTACT, true);
}
*/
package org.mxchange.addressbook.database.frontend.contact;
+import java.sql.SQLException;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.database.frontend.DatabaseWrapper;
import org.mxchange.addressbook.exceptions.BadTokenException;
* Some "getter" for total contacts count
*
* @return Total contacts count
+ * @throws java.sql.SQLException If any SQL error occurs
*/
- public int getContactsCount ();
+ public int getContactsCount () throws SQLException;
/**
* Checks if given Contact is found
* Checks whether own contact is found
*
* @return Whether own contact is found
+ * @throws java.sql.SQLException If any SQL error occurs
*/
- public boolean isOwnContactFound ();
+ public boolean isOwnContactFound () throws SQLException;
}
*/
package org.mxchange.addressbook.manager.contact;
+import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
- // Deligate this call to frontend
- boolean isAdded = this.getContactDatabase().isOwnContactFound();
+ // Init variable
+ boolean isAdded = false;
+
+ try {
+ // Deligate this call to frontend
+ isAdded = this.getContactDatabase().isOwnContactFound();
+ } catch (final SQLException ex) {
+ // Something bad happened
+ this.abortProgramWithException(ex);
+ }
// Trace message
this.getLogger().trace(MessageFormat.format("isAdded={0} : EXIT!", isAdded)); //NOI18N
*/
@Override
public final int size () {
- return this.getContactDatabase().getContactsCount();
+ // Init size
+ int size = -1;
+
+ try {
+ size = this.getContactDatabase().getContactsCount();
+ } catch (final SQLException ex) {
+ // Something happened
+ this.abortProgramWithException(ex);
+ }
+
+ // Return amount
+ return size;
}
/**