Sha256: 20c9454568737683c7e5b31e69aca8febac330f3bb4dbd88ff0c9fa46749a0db

Contents?: true

Size: 1.21 KB

Versions: 30

Compression:

Stored size: 1.21 KB

Contents

package org.embulk.output.sqlserver.setter;

import java.io.IOException;
import java.sql.SQLException;

import org.embulk.output.jdbc.BatchInsert;
import org.embulk.output.jdbc.JdbcColumn;
import org.embulk.output.jdbc.setter.ByteColumnSetter;
import org.embulk.output.jdbc.setter.DefaultValueSetter;

public class SQLServerByteColumnSetter
        extends ByteColumnSetter
{
    private static final short MIN_VALUE = 0;
    private static final short MAX_VALUE = 255;

    public SQLServerByteColumnSetter(BatchInsert batch, JdbcColumn column,
            DefaultValueSetter defaultValue)
    {
        super(batch, column, defaultValue);
    }

    @Override
    public void longValue(long v) throws IOException, SQLException
    {
        // SQLServer TINYINT value is from 0 to 255
        if (v > MAX_VALUE || v < MIN_VALUE) {
            defaultValue.setByte();
        } else {
            batch.setShort((short) v);
        }
    }

    @Override
    public void stringValue(String v) throws IOException, SQLException
    {
        short sv;
        try {
            sv = Short.parseShort(v);
        } catch (NumberFormatException e) {
            defaultValue.setByte();
            return;
        }
        longValue(sv);
    }
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
embulk-output-sqlserver-0.8.7 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.6 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.5 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.4 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.3 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.2 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.1 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.8.0 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.13 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.12 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.11 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.10 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.9 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.8 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.7 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.6 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.5 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.4 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.3 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java
embulk-output-sqlserver-0.7.2 src/main/java/org/embulk/output/sqlserver/setter/SQLServerByteColumnSetter.java