]> git.mxchange.org Git - jcore.git/commitdiff
Added more thrown exceptions + catched some + added getting of SQL warnings into...
authorRoland Haeder <roland@mxchange.org>
Thu, 13 Aug 2015 13:31:05 +0000 (15:31 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 13 Aug 2015 13:34:58 +0000 (15:34 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/application/Application.java
src/org/mxchange/jcore/client/Client.java
src/org/mxchange/jcore/client/gui/ClientFrame.java
src/org/mxchange/jcore/database/frontend/BaseDatabaseFrontend.java
src/org/mxchange/jcore/database/result/DatabaseResult.java
src/org/mxchange/jcore/database/result/Result.java
src/org/mxchange/jcore/manager/Manageable.java
src/org/mxchange/jcore/manager/database/ManageableDatabase.java
src/org/mxchange/jcore/model/swing/contact/ContactTableModel.java

index fdcc4d64dae6ef6a349758c440250d327d3912fc..5a28624c179a1b453d1ca2c4fc7fc7c1327e3b3d 100644 (file)
@@ -38,8 +38,8 @@ public interface Application extends FrameworkInterface {
 
        /**
         * Shutdown the application
-        * @throws java.sql.SQLException If an SQL error occurs
         * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If a SQL error occurs
         */
-       public void doShutdown () throws SQLException, IOException;
+       public void doShutdown () throws IOException, SQLException;
 }
index 1d3fd1ec2d0fe3606ef16c1e1850883f81e9f861..5131773868818c62762bce3091924d76818a593c 100644 (file)
@@ -30,10 +30,10 @@ public interface Client extends FrameworkInterface {
 
        /**
         * Shuts down the client and therefore whole application
-        * @throws java.sql.SQLException If an SQL error occurs
         * @throws java.io.IOException If an IO error occurs
+        * @throws java.sql.SQLException If a SQL error occurs
         */
-       public void doShutdown () throws SQLException, IOException;
+       public void doShutdown () throws IOException, SQLException;
 
        /**
         * Displays a message to the user
index 6f4f22caa0e50b41d6f758471f40d7947ab9cd17..d769cc9adb96706c70775a45791859038857860b 100644 (file)
  */
 package org.mxchange.jcore.client.gui;
 
+import java.io.IOException;
 import org.mxchange.jcore.FrameworkInterface;
 import org.mxchange.jcore.client.Client;
 import org.mxchange.jcore.contact.Contact;
+import org.mxchange.jcore.exceptions.BadTokenException;
 import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
 
 /**
@@ -50,8 +52,10 @@ public interface ClientFrame extends FrameworkInterface {
         * call this method.
         *
         * @param client Client instance
+        * @throws java.io.IOException If an IO error was found
+        * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
         */
-       public void setupFrame (final Client client);
+       public void setupFrame (final Client client) throws IOException, BadTokenException;
 
        /**
         * Initializes frame
index 7e7a6a3788ce9c794723648b880b2a7e295da0a5..bf7971d118d27782aaad0969ecfdd6ff82cccb7f 100644 (file)
 package org.mxchange.jcore.database.frontend;
 
 import java.lang.reflect.InvocationTargetException;
+import java.sql.ResultSet;
 import java.sql.SQLException;
 import org.mxchange.jcore.BaseFrameworkSystem;
 import org.mxchange.jcore.database.backend.DatabaseBackend;
+import org.mxchange.jcore.database.result.DatabaseResult;
+import org.mxchange.jcore.database.result.Result;
+import org.mxchange.jcore.database.storage.Storeable;
 import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
 import org.mxchange.jcore.factory.database.backend.BackendFactory;
 
@@ -64,4 +68,23 @@ public abstract class BaseDatabaseFrontend extends BaseFrameworkSystem implement
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
        }
+
+       /**
+        * Gets a Result back from given ResultSet instance
+        *
+        * @param resultSet ResultSet instance from SQL driver
+        * @return A typorized Result instance
+        * @throws java.sql.SQLException If an SQL error occurs
+        */
+       @Override
+       public Result<? extends Storeable> getResultFromSet (final ResultSet resultSet) throws SQLException {
+               // Init result instance
+               Result<? extends Storeable> result = new DatabaseResult();
+
+               // Attach all possible warnings
+               result.setWarnings(resultSet.getWarnings());
+
+               // And return it
+               return result;
+       }
 }
index c8dca70e474a939e6229bcac66579151d2ca0a15..efe8748d861705be80dcecba383273960b614942 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcore.database.result;
 
+import java.sql.SQLWarning;
 import java.util.Iterator;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -32,6 +33,11 @@ public class DatabaseResult extends BaseFrameworkSystem implements Result<Storea
         */
        private final SortedSet<Storeable> result;
 
+       /**
+        * SQLWarning instance
+        */
+       private SQLWarning warnings;
+
        /**
         * Default constructor
         */
@@ -54,9 +60,24 @@ public class DatabaseResult extends BaseFrameworkSystem implements Result<Storea
                this.result.add(storeable);
        }
 
+       /**
+        * Getter for warnings
+        *
+        * @return SQLQarning from ResultSet instance
+        */
        @Override
-       public int size () {
-               return this.result.size();
+       public SQLWarning getWarnings () {
+               return this.warnings;
+       }
+
+       /**
+        * Setter for warnings
+        *
+        * @param warnings SQLQarning from ResultSet instance
+        */
+       @Override
+       public void setWarnings (final SQLWarning warnings) {
+               this.warnings = warnings;
        }
 
        @Override
@@ -82,4 +103,9 @@ public class DatabaseResult extends BaseFrameworkSystem implements Result<Storea
                // Call iterator's method
                this.iterator().remove();
        }
+
+       @Override
+       public int size () {
+               return this.result.size();
+       }
 }
index 96056ccda0e1d51e63fdf581e24c7198306e969d..4c8217ba7ac1c12355f450fa368bbadd3c5ee787 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcore.database.result;
 
+import java.sql.SQLWarning;
 import java.util.Iterator;
 import org.mxchange.jcore.FrameworkInterface;
 import org.mxchange.jcore.database.storage.Storeable;
@@ -35,6 +36,20 @@ public interface Result<T extends Storeable> extends FrameworkInterface, Iterato
         */
        public void add (final Storeable storeable);
 
+       /**
+        * Setter for warnings
+        *
+        * @param warnings SQLQarning from ResultSet instance
+        */
+       public void setWarnings (final SQLWarning warnings);
+
+       /**
+        * Getter for warnings
+        *
+        * @return SQLQarning from ResultSet instance
+        */
+       public SQLWarning getWarnings ();
+
        /**
         * Returns size of result
         *
index f77ef2e76ca31349528f7f8809fa239bb3b95620..3aed987f8f78e7d469953f15b5c89232976a6b04 100644 (file)
@@ -29,8 +29,8 @@ public interface Manageable extends FrameworkInterface {
 
        /**
         * Shuts down this contact manager
-        * @throws java.sql.SQLException If any SQL error occurs
-        * @throws java.io.IOException If any IO error occurs
+        * @throws java.sql.SQLException If an SQL error occurs
+        * @throws java.io.IOException If an IO error occurs
         */
        public void doShutdown () throws SQLException, IOException;
 }
index 483b917ac0c081a1eaf287b0a55f23f329675371..91fcb7ac12bf67b6d5d175d16b34643ccae14ec5 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcore.manager.database;
 
+import java.lang.reflect.InvocationTargetException;
 import org.mxchange.jcore.manager.Manageable;
 
 /**
@@ -53,8 +54,11 @@ public interface ManageableDatabase extends Manageable {
         * @param rowIndex Row index
         * @param columnIndex Column index
         * @return Value from given row/column
+        * @throws java.lang.NoSuchMethodException If a non-existing method should be invoked
+        * @throws java.lang.IllegalAccessException If the method cannot be accessed
+        * @throws java.lang.reflect.InvocationTargetException Something other happened?
         */
-       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex);
+       public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
 
        /**
         * Getter for column count
index a24da4a5db79f284332f177cdaadd17165951c6c..39ae1deee3c3808a4d423f701c1b6f435490243c 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcore.model.swing.contact;
 
+import java.lang.reflect.InvocationTargetException;
 import java.text.MessageFormat;
 import javax.swing.table.TableModel;
 import org.mxchange.jcore.client.Client;
@@ -86,8 +87,19 @@ public class ContactTableModel extends BaseModel implements TableModel {
                // Get manager
                ManageableDatabase manager = (ManageableDatabase) this.getClient().getManager();
 
-               // Deligate this call to contact manager
-               return manager.getValueFromRowColumn(rowIndex, columnIndex);
+               // Init value
+               Object value = null;
+
+               try {
+                       // Deligate this call to contact manager
+                       value = manager.getValueFromRowColumn(rowIndex, columnIndex);
+               } catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
+                       // Abort here
+                       this.abortProgramWithException(ex);
+               }
+
+               // Return it
+               return value;
        }
 
        @Override