]> git.mxchange.org Git - jcore.git/commitdiff
Added support for Long and currently null is not supported
authorRoland Haeder <roland@mxchange.org>
Mon, 17 Aug 2015 06:42:53 +0000 (08:42 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 17 Aug 2015 06:44:22 +0000 (08:44 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/org/mxchange/jcore/database/backend/mysql/MySqlDatabaseBackend.java

index 11f9e209ccbafa48bd9b98c62d39c60a82fdb84e..a0a17c3dfb2b68018f766868295bbd207eff4f52 100644 (file)
@@ -118,11 +118,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                this.getLogger().debug("Connection is up, preparing some statements ..."); //NOI18N
 
                // Set prepared statement
-               this.totalRows = connection.prepareStatement("SELECT COUNT(`?`) AS `cnt` FROM `?` LIMIT 1");
-
-               // Set values in prepared statement
-               this.totalRows.setObject(1, this.getFrontend().getIdName());
-               this.totalRows.setObject(2, this.getTableName());
+               this.totalRows = connection.prepareStatement(String.format("SELECT COUNT(`%s`) AS `cnt` FROM `%s` LIMIT 1", this.getFrontend().getIdName(), this.getTableName()));
 
                // Trace message
                this.getLogger().trace("EXIT!"); //NOI18N
@@ -348,7 +344,7 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
                        Object value = valueIterator.next();
 
                        //Debug message
-                       this.getLogger().debug(MessageFormat.format("value={0} at index={1}", value, index));
+                       this.getLogger().debug(MessageFormat.format("index={1} has value={0}", value, index));
 
                        // Detect type again
                        if (value instanceof Boolean) {
@@ -369,15 +365,24 @@ public class MySqlDatabaseBackend extends BaseDatabaseBackend implements Databas
 
                                // Found ineteger
                                statement.setInt(index, (int) value);
+                       } else if (value instanceof Long) {
+                               // Debug message
+                               this.getLogger().debug(MessageFormat.format("Setting long value={0} for index={1}", value, index));
+
+                               // Found ineteger
+                               statement.setLong(index, (long) value);
                        } else if (value instanceof Float) {
                                // Debug message
                                this.getLogger().debug(MessageFormat.format("Setting float value={0} for index={1}", value, index));
 
                                // Found ineteger
                                statement.setFloat(index, (float) value);
+                       } else if (value == null) {
+                               // Debug message
+                               this.getLogger().warn(MessageFormat.format("Null value in index={0} is not supported (yet)", index));
                        } else {
                                // Not parseable type
-                               throw new SQLException(MessageFormat.format("Cannot handle value={0} for index={1} in table {2}", value, index, this.getTableName()));
+                               throw new SQLException(MessageFormat.format("Cannot handle value({0})={1} for index={2} in table {3}", value.getClass().getSimpleName(), value, index, this.getTableName()));
                        }
 
                        // Increment index