Browse Source

支持mysql类型bigint同步到oracle类型number

AE86 3 years ago
parent
commit
8d82a2c3fc

+ 11 - 0
dbsyncer-connector/src/main/java/org/dbsyncer/connector/database/setter/NumericSetter.java

@@ -4,6 +4,7 @@ import org.dbsyncer.connector.ConnectorException;
 import org.dbsyncer.connector.database.AbstractSetter;
 import org.dbsyncer.connector.database.AbstractSetter;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.sql.PreparedStatement;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.SQLException;
 
 
@@ -21,6 +22,16 @@ public class NumericSetter extends AbstractSetter<BigDecimal> {
             ps.setInt(i, integer);
             ps.setInt(i, integer);
             return;
             return;
         }
         }
+        if(val instanceof Long){
+            Long l = (Long) val;
+            ps.setLong(i, l);
+            return;
+        }
+        if(val instanceof BigInteger){
+            BigInteger b = (BigInteger) val;
+            ps.setLong(i, new Long(b.longValue()));
+            return;
+        }
         throw new ConnectorException(String.format("NumericSetter can not find type [%s], val [%s]", type, val));
         throw new ConnectorException(String.format("NumericSetter can not find type [%s], val [%s]", type, val));
     }
     }
 }
 }