View Issue Details

IDProjectCategoryView StatusLast Update
0001757SymmetricDSBugpublic2014-06-17 00:27
Reporterhrk Assigned Tochenson  
Prioritynormal 
Status closedResolutionfixed 
Product Version3.5.22 
Target Version3.6.0Fixed in Version3.6.0 
Summary0001757: java.lang.NumberFormatException w/ MSSQL and BIT column
DescriptionIt appears that SymmetricDS expects to parse a BIT field as an Integer, and fails in front of the "true" String from the database.

DB is recognized as databaseName=Microsoft SQL Server, databaseVersion=10.50, driverName=jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, driverVersion=1.2.4

BUG is being detected on 3.6.0-SNAPSHOT-20140611 not 3.5.22
Additional Information[caricatori-slave-001] - PullService - Immediate pull requested while in reload mode
[caricatori-slave-001] - MsSql2008DatabasePlatform - Could not convert a value of true for column Sincrono of type BIT
[caricatori-slave-001] - MsSql2008DatabasePlatform - For input string: "true"
java.lang.NumberFormatException: For input string: "true"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:580)
        at java.math.BigInteger.<init>(BigInteger.java:453)
        at java.math.BigInteger.<init>(BigInteger.java:589)
        at org.jumpmind.db.platform.AbstractDatabasePlatform.parseInteger(AbstractDatabasePlatform.java:442)
        at org.jumpmind.db.platform.AbstractDatabasePlatform.getObjectValue(AbstractDatabasePlatform.java:391)
        at org.jumpmind.db.platform.AbstractDatabasePlatform.getObjectValues(AbstractDatabasePlatform.java:351)
        at org.jumpmind.db.platform.AbstractDatabasePlatform.getObjectValues(AbstractDatabasePlatform.java:339)
        at org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter.execute(DefaultDatabaseWriter.java:782)
        at org.jumpmind.symmetric.io.data.writer.DefaultDatabaseWriter.insert(DefaultDatabaseWriter.java:170)
        at org.jumpmind.symmetric.io.data.writer.AbstractDatabaseWriter.write(AbstractDatabaseWriter.java:154)
        at org.jumpmind.symmetric.io.data.writer.AbstractDatabaseWriter.write(AbstractDatabaseWriter.java:131)
        at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
        at org.jumpmind.symmetric.model.ProcessInfoDataWriter.write(ProcessInfoDataWriter.java:65)
        at org.jumpmind.symmetric.io.data.writer.NestedDataWriter.write(NestedDataWriter.java:64)
        at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:235)
        at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:199)
        at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:169)
        at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:115)
        at org.jumpmind.symmetric.service.impl.DataLoaderService$LoadIntoDatabaseOnArrivalListener.end(DataLoaderService.java:802)
        at org.jumpmind.symmetric.io.data.writer.StagingDataWriter.notifyEndBatch(StagingDataWriter.java:75)
        at org.jumpmind.symmetric.io.data.writer.AbstractProtocolDataWriter.end(AbstractProtocolDataWriter.java:220)
        at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:129)
        at org.jumpmind.symmetric.service.impl.DataLoaderService.loadDataFromTransport(DataLoaderService.java:431)
        at org.jumpmind.symmetric.service.impl.DataLoaderService.loadDataFromPull(DataLoaderService.java:269)
        at org.jumpmind.symmetric.service.impl.PullService.execute(PullService.java:133)
        at org.jumpmind.symmetric.service.impl.NodeCommunicationService$2.run(NodeCommunicationService.java:307)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
TagsNo tags attached.

Activities

hrk

2014-06-11 10:07

reporter  

symmetric-0001757.patch (1,464 bytes)   
Index: symmetric-db/src/main/java/org/jumpmind/db/platform/AbstractDatabasePlatform.java
===================================================================
--- symmetric-db/src/main/java/org/jumpmind/db/platform/AbstractDatabasePlatform.java	(revisione 8366)
+++ symmetric-db/src/main/java/org/jumpmind/db/platform/AbstractDatabasePlatform.java	(copia locale)
@@ -387,11 +388,17 @@
                 }
             } else if (type == Types.BIGINT) {
                 objectValue = parseBigInteger(value);
-            } else if (type == Types.INTEGER || type == Types.SMALLINT || type == Types.BIT) {
+            } else if (type == Types.INTEGER || type == Types.SMALLINT) {
                 objectValue = parseInteger(value);
             } else if (type == Types.NUMERIC || type == Types.DECIMAL || type == Types.FLOAT
                     || type == Types.DOUBLE || type == Types.REAL) {
                 objectValue = parseBigDecimal(value);
+            } else if (type == Types.BIT) {
+                if (StringUtils.isNumeric(value)) {
+                    objectValue = parseInteger(value);
+                } else {
+                    objectValue = Boolean.parseBoolean(value);
+                }
             } else if (type == Types.BOOLEAN) {
                 objectValue = value.equals("1") ? Boolean.TRUE : Boolean.FALSE;
             } else if (!(column.getJdbcTypeName() != null && column.getJdbcTypeName().toUpperCase()
symmetric-0001757.patch (1,464 bytes)   

hrk

2014-06-11 10:08

reporter   ~0000534

Uploaded patch which handles both numeric and boolean BIT columns. Contributor agreement should have been electronically sent/received. If not, this counts as an agreement to the licensing to JumpMind.

Related Changesets

SymmetricDS: master 16b20e5a

2014-06-11 08:36:24

chenson

Details Diff
0001757: java.lang.NumberFormatException w/ MSSQL and BIT column Affected Issues
0001757
mod - symmetric-db/src/main/java/org/jumpmind/db/platform/AbstractDatabasePlatform.java Diff File

Issue History

Date Modified Username Field Change
2014-06-11 09:36 hrk New Issue
2014-06-11 10:07 hrk File Added: symmetric-0001757.patch
2014-06-11 10:08 hrk Note Added: 0000534
2014-06-11 12:30 chenson Assigned To => chenson
2014-06-11 12:30 chenson Status new => assigned
2014-06-11 12:30 chenson Fixed in Version => 3.6.0
2014-06-11 12:30 chenson Target Version => 3.6.0
2014-06-11 12:30 chenson Status assigned => resolved
2014-06-11 12:30 chenson Resolution open => fixed
2014-06-11 13:00 Changeset attached => SymmetricDS trunk r8367
2014-06-17 00:27 chenson Status resolved => closed
2015-07-31 01:49 chenson Changeset attached => SymmetricDS master 16b20e5a