embulk-output-jdbc 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/build.gradle +2 -2
- data/classpath/embulk-output-jdbc-0.4.2.jar +0 -0
- data/lib/embulk/output/jdbc.rb +3 -3
- data/src/main/java/org/embulk/output/JdbcOutputPlugin.java +137 -138
- data/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java +972 -973
- data/src/main/java/org/embulk/output/jdbc/BatchInsert.java +52 -53
- data/src/main/java/org/embulk/output/jdbc/JdbcColumn.java +116 -116
- data/src/main/java/org/embulk/output/jdbc/JdbcColumnOption.java +34 -34
- data/src/main/java/org/embulk/output/jdbc/JdbcOutputConnection.java +492 -492
- data/src/main/java/org/embulk/output/jdbc/JdbcOutputConnector.java +8 -8
- data/src/main/java/org/embulk/output/jdbc/JdbcSchema.java +60 -60
- data/src/main/java/org/embulk/output/jdbc/JdbcUtils.java +153 -155
- data/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java +200 -200
- data/src/main/java/org/embulk/output/jdbc/ToString.java +54 -54
- data/src/main/java/org/embulk/output/jdbc/ToStringMap.java +34 -35
- data/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java +68 -70
- data/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java +53 -54
- data/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java +75 -76
- data/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java +44 -45
- data/src/main/java/org/embulk/output/jdbc/setter/ColumnSetterFactory.java +196 -196
- data/src/main/java/org/embulk/output/jdbc/setter/ColumnSetterVisitor.java +95 -96
- data/src/main/java/org/embulk/output/jdbc/setter/DefaultValueSetter.java +48 -48
- data/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java +60 -61
- data/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java +60 -61
- data/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java +75 -76
- data/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java +71 -72
- data/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java +58 -59
- data/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java +53 -53
- data/src/main/java/org/embulk/output/jdbc/setter/NullDefaultValueSetter.java +105 -105
- data/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java +58 -59
- data/src/main/java/org/embulk/output/jdbc/setter/ShortColumnSetter.java +75 -76
- data/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java +43 -43
- data/src/main/java/org/embulk/output/jdbc/setter/SqlDateColumnSetter.java +58 -59
- data/src/main/java/org/embulk/output/jdbc/setter/SqlTimeColumnSetter.java +58 -59
- data/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java +58 -58
- data/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java +58 -59
- data/src/test/java/org/embulk/output/TestJdbcOutputPlugin.java +5 -5
- metadata +3 -3
- data/classpath/embulk-output-jdbc-0.4.1.jar +0 -0
@@ -1,105 +1,105 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import java.io.IOException;
|
4
|
-
import java.sql.SQLException;
|
5
|
-
import org.embulk.output.jdbc.JdbcColumn;
|
6
|
-
import org.embulk.output.jdbc.BatchInsert;
|
7
|
-
|
8
|
-
public class NullDefaultValueSetter
|
9
|
-
extends DefaultValueSetter
|
10
|
-
{
|
11
|
-
public NullDefaultValueSetter(BatchInsert batch, JdbcColumn column)
|
12
|
-
{
|
13
|
-
super(batch, column);
|
14
|
-
}
|
15
|
-
|
16
|
-
@Override
|
17
|
-
public void setNull() throws IOException, SQLException
|
18
|
-
{
|
19
|
-
batch.setNull(column.getSqlType());
|
20
|
-
}
|
21
|
-
|
22
|
-
@Override
|
23
|
-
public void setBoolean() throws IOException, SQLException
|
24
|
-
{
|
25
|
-
batch.setNull(column.getSqlType());
|
26
|
-
}
|
27
|
-
|
28
|
-
@Override
|
29
|
-
public void setByte() throws IOException, SQLException
|
30
|
-
{
|
31
|
-
batch.setNull(column.getSqlType());
|
32
|
-
}
|
33
|
-
|
34
|
-
@Override
|
35
|
-
public void setShort() throws IOException, SQLException
|
36
|
-
{
|
37
|
-
batch.setNull(column.getSqlType());
|
38
|
-
}
|
39
|
-
|
40
|
-
@Override
|
41
|
-
public void setInt() throws IOException, SQLException
|
42
|
-
{
|
43
|
-
batch.setNull(column.getSqlType());
|
44
|
-
}
|
45
|
-
|
46
|
-
@Override
|
47
|
-
public void setLong() throws IOException, SQLException
|
48
|
-
{
|
49
|
-
batch.setNull(column.getSqlType());
|
50
|
-
}
|
51
|
-
|
52
|
-
@Override
|
53
|
-
public void setFloat() throws IOException, SQLException
|
54
|
-
{
|
55
|
-
batch.setNull(column.getSqlType());
|
56
|
-
}
|
57
|
-
|
58
|
-
@Override
|
59
|
-
public void setDouble() throws IOException, SQLException
|
60
|
-
{
|
61
|
-
batch.setNull(column.getSqlType());
|
62
|
-
}
|
63
|
-
|
64
|
-
@Override
|
65
|
-
public void setBigDecimal() throws IOException, SQLException
|
66
|
-
{
|
67
|
-
batch.setNull(column.getSqlType());
|
68
|
-
}
|
69
|
-
|
70
|
-
@Override
|
71
|
-
public void setString() throws IOException, SQLException
|
72
|
-
{
|
73
|
-
batch.setNull(column.getSqlType());
|
74
|
-
}
|
75
|
-
|
76
|
-
@Override
|
77
|
-
public void setNString() throws IOException, SQLException
|
78
|
-
{
|
79
|
-
batch.setNull(column.getSqlType());
|
80
|
-
}
|
81
|
-
|
82
|
-
@Override
|
83
|
-
public void setBytes() throws IOException, SQLException
|
84
|
-
{
|
85
|
-
batch.setNull(column.getSqlType());
|
86
|
-
}
|
87
|
-
|
88
|
-
@Override
|
89
|
-
public void setSqlDate() throws IOException, SQLException
|
90
|
-
{
|
91
|
-
batch.setNull(column.getSqlType());
|
92
|
-
}
|
93
|
-
|
94
|
-
@Override
|
95
|
-
public void setSqlTime() throws IOException, SQLException
|
96
|
-
{
|
97
|
-
batch.setNull(column.getSqlType());
|
98
|
-
}
|
99
|
-
|
100
|
-
@Override
|
101
|
-
public void setSqlTimestamp() throws IOException, SQLException
|
102
|
-
{
|
103
|
-
batch.setNull(column.getSqlType());
|
104
|
-
}
|
105
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.sql.SQLException;
|
5
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
6
|
+
import org.embulk.output.jdbc.BatchInsert;
|
7
|
+
|
8
|
+
public class NullDefaultValueSetter
|
9
|
+
extends DefaultValueSetter
|
10
|
+
{
|
11
|
+
public NullDefaultValueSetter(BatchInsert batch, JdbcColumn column)
|
12
|
+
{
|
13
|
+
super(batch, column);
|
14
|
+
}
|
15
|
+
|
16
|
+
@Override
|
17
|
+
public void setNull() throws IOException, SQLException
|
18
|
+
{
|
19
|
+
batch.setNull(column.getSqlType());
|
20
|
+
}
|
21
|
+
|
22
|
+
@Override
|
23
|
+
public void setBoolean() throws IOException, SQLException
|
24
|
+
{
|
25
|
+
batch.setNull(column.getSqlType());
|
26
|
+
}
|
27
|
+
|
28
|
+
@Override
|
29
|
+
public void setByte() throws IOException, SQLException
|
30
|
+
{
|
31
|
+
batch.setNull(column.getSqlType());
|
32
|
+
}
|
33
|
+
|
34
|
+
@Override
|
35
|
+
public void setShort() throws IOException, SQLException
|
36
|
+
{
|
37
|
+
batch.setNull(column.getSqlType());
|
38
|
+
}
|
39
|
+
|
40
|
+
@Override
|
41
|
+
public void setInt() throws IOException, SQLException
|
42
|
+
{
|
43
|
+
batch.setNull(column.getSqlType());
|
44
|
+
}
|
45
|
+
|
46
|
+
@Override
|
47
|
+
public void setLong() throws IOException, SQLException
|
48
|
+
{
|
49
|
+
batch.setNull(column.getSqlType());
|
50
|
+
}
|
51
|
+
|
52
|
+
@Override
|
53
|
+
public void setFloat() throws IOException, SQLException
|
54
|
+
{
|
55
|
+
batch.setNull(column.getSqlType());
|
56
|
+
}
|
57
|
+
|
58
|
+
@Override
|
59
|
+
public void setDouble() throws IOException, SQLException
|
60
|
+
{
|
61
|
+
batch.setNull(column.getSqlType());
|
62
|
+
}
|
63
|
+
|
64
|
+
@Override
|
65
|
+
public void setBigDecimal() throws IOException, SQLException
|
66
|
+
{
|
67
|
+
batch.setNull(column.getSqlType());
|
68
|
+
}
|
69
|
+
|
70
|
+
@Override
|
71
|
+
public void setString() throws IOException, SQLException
|
72
|
+
{
|
73
|
+
batch.setNull(column.getSqlType());
|
74
|
+
}
|
75
|
+
|
76
|
+
@Override
|
77
|
+
public void setNString() throws IOException, SQLException
|
78
|
+
{
|
79
|
+
batch.setNull(column.getSqlType());
|
80
|
+
}
|
81
|
+
|
82
|
+
@Override
|
83
|
+
public void setBytes() throws IOException, SQLException
|
84
|
+
{
|
85
|
+
batch.setNull(column.getSqlType());
|
86
|
+
}
|
87
|
+
|
88
|
+
@Override
|
89
|
+
public void setSqlDate() throws IOException, SQLException
|
90
|
+
{
|
91
|
+
batch.setNull(column.getSqlType());
|
92
|
+
}
|
93
|
+
|
94
|
+
@Override
|
95
|
+
public void setSqlTime() throws IOException, SQLException
|
96
|
+
{
|
97
|
+
batch.setNull(column.getSqlType());
|
98
|
+
}
|
99
|
+
|
100
|
+
@Override
|
101
|
+
public void setSqlTimestamp() throws IOException, SQLException
|
102
|
+
{
|
103
|
+
batch.setNull(column.getSqlType());
|
104
|
+
}
|
105
|
+
}
|
@@ -1,59 +1,58 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import java.util.Calendar;
|
4
|
-
import java.io.IOException;
|
5
|
-
import java.sql.SQLException;
|
6
|
-
import org.embulk.spi.time.Timestamp;
|
7
|
-
import org.embulk.
|
8
|
-
import org.embulk.output.jdbc.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import java.util.Calendar;
|
4
|
+
import java.io.IOException;
|
5
|
+
import java.sql.SQLException;
|
6
|
+
import org.embulk.spi.time.Timestamp;
|
7
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
8
|
+
import org.embulk.output.jdbc.BatchInsert;
|
9
|
+
|
10
|
+
public class PassThroughColumnSetter
|
11
|
+
extends ColumnSetter
|
12
|
+
{
|
13
|
+
private final Calendar calendar;
|
14
|
+
|
15
|
+
public PassThroughColumnSetter(BatchInsert batch, JdbcColumn column,
|
16
|
+
DefaultValueSetter defaultValue,
|
17
|
+
Calendar calendar)
|
18
|
+
{
|
19
|
+
super(batch, column, defaultValue);
|
20
|
+
this.calendar = calendar;
|
21
|
+
}
|
22
|
+
|
23
|
+
@Override
|
24
|
+
public void nullValue() throws IOException, SQLException
|
25
|
+
{
|
26
|
+
batch.setNull(column.getSqlType());
|
27
|
+
}
|
28
|
+
|
29
|
+
@Override
|
30
|
+
public void booleanValue(boolean v) throws IOException, SQLException
|
31
|
+
{
|
32
|
+
batch.setBoolean(v);
|
33
|
+
}
|
34
|
+
|
35
|
+
@Override
|
36
|
+
public void longValue(long v) throws IOException, SQLException
|
37
|
+
{
|
38
|
+
batch.setLong(v);
|
39
|
+
}
|
40
|
+
|
41
|
+
@Override
|
42
|
+
public void doubleValue(double v) throws IOException, SQLException
|
43
|
+
{
|
44
|
+
batch.setDouble(v);
|
45
|
+
}
|
46
|
+
|
47
|
+
@Override
|
48
|
+
public void stringValue(String v) throws IOException, SQLException
|
49
|
+
{
|
50
|
+
batch.setString(v);
|
51
|
+
}
|
52
|
+
|
53
|
+
@Override
|
54
|
+
public void timestampValue(Timestamp v) throws IOException, SQLException
|
55
|
+
{
|
56
|
+
batch.setSqlTimestamp(v, calendar);
|
57
|
+
}
|
58
|
+
}
|
@@ -1,76 +1,75 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import java.io.IOException;
|
4
|
-
import java.sql.SQLException;
|
5
|
-
import java.math.RoundingMode;
|
6
|
-
import com.google.common.math.DoubleMath;
|
7
|
-
import org.embulk.spi.
|
8
|
-
import org.embulk.
|
9
|
-
import org.embulk.output.jdbc.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.sql.SQLException;
|
5
|
+
import java.math.RoundingMode;
|
6
|
+
import com.google.common.math.DoubleMath;
|
7
|
+
import org.embulk.spi.time.Timestamp;
|
8
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
9
|
+
import org.embulk.output.jdbc.BatchInsert;
|
10
|
+
|
11
|
+
public class ShortColumnSetter
|
12
|
+
extends ColumnSetter
|
13
|
+
{
|
14
|
+
public ShortColumnSetter(BatchInsert batch, JdbcColumn column,
|
15
|
+
DefaultValueSetter defaultValue)
|
16
|
+
{
|
17
|
+
super(batch, column, defaultValue);
|
18
|
+
}
|
19
|
+
|
20
|
+
@Override
|
21
|
+
public void nullValue() throws IOException, SQLException
|
22
|
+
{
|
23
|
+
defaultValue.setShort();
|
24
|
+
}
|
25
|
+
|
26
|
+
@Override
|
27
|
+
public void booleanValue(boolean v) throws IOException, SQLException
|
28
|
+
{
|
29
|
+
batch.setShort(v ? (short) 1 : (short) 0);
|
30
|
+
}
|
31
|
+
|
32
|
+
@Override
|
33
|
+
public void longValue(long v) throws IOException, SQLException
|
34
|
+
{
|
35
|
+
if (v > Short.MAX_VALUE || v < Short.MIN_VALUE) {
|
36
|
+
defaultValue.setShort();
|
37
|
+
} else {
|
38
|
+
batch.setShort((short) v);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
@Override
|
43
|
+
public void doubleValue(double v) throws IOException, SQLException
|
44
|
+
{
|
45
|
+
long lv;
|
46
|
+
try {
|
47
|
+
// TODO configurable rounding mode
|
48
|
+
lv = DoubleMath.roundToLong(v, RoundingMode.HALF_UP);
|
49
|
+
} catch (ArithmeticException ex) {
|
50
|
+
// NaN / Infinite / -Infinite
|
51
|
+
defaultValue.setShort();
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
longValue(lv);
|
55
|
+
}
|
56
|
+
|
57
|
+
@Override
|
58
|
+
public void stringValue(String v) throws IOException, SQLException
|
59
|
+
{
|
60
|
+
short sv;
|
61
|
+
try {
|
62
|
+
sv = Short.parseShort(v);
|
63
|
+
} catch (NumberFormatException e) {
|
64
|
+
defaultValue.setShort();
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
batch.setShort(sv);
|
68
|
+
}
|
69
|
+
|
70
|
+
@Override
|
71
|
+
public void timestampValue(Timestamp v) throws IOException, SQLException
|
72
|
+
{
|
73
|
+
defaultValue.setShort();
|
74
|
+
}
|
75
|
+
}
|