embulk-output-jdbc 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/build.gradle +2 -2
- data/classpath/{embulk-output-jdbc-0.2.3.jar → embulk-output-jdbc-0.2.4.jar} +0 -0
- data/lib/embulk/output/jdbc.rb +3 -3
- data/src/main/java/org/embulk/output/JdbcOutputPlugin.java +120 -120
- data/src/main/java/org/embulk/output/jdbc/AbstractJdbcOutputPlugin.java +755 -756
- data/src/main/java/org/embulk/output/jdbc/BatchInsert.java +54 -54
- data/src/main/java/org/embulk/output/jdbc/JdbcOutputConnector.java +8 -8
- data/src/main/java/org/embulk/output/jdbc/JdbcSchema.java +37 -37
- data/src/main/java/org/embulk/output/jdbc/JdbcUtils.java +155 -155
- data/src/main/java/org/embulk/output/jdbc/RetryExecutor.java +105 -105
- data/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java +52 -52
- data/src/main/java/org/embulk/output/jdbc/setter/ColumnSetterFactory.java +137 -137
- data/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java +51 -51
- data/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java +62 -62
- data/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java +43 -43
- data/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java +38 -38
- data/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java +48 -48
- data/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java +48 -48
- data/src/test/java/org/embulk/output/TestJdbcOutputPlugin.java +5 -5
- metadata +3 -3
@@ -1,51 +1,51 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import java.io.IOException;
|
4
|
-
import java.sql.SQLException;
|
5
|
-
import org.embulk.spi.ColumnVisitor;
|
6
|
-
import org.embulk.spi.PageReader;
|
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 DoubleColumnSetter
|
12
|
-
extends ColumnSetter
|
13
|
-
{
|
14
|
-
public DoubleColumnSetter(BatchInsert batch, PageReader pageReader,
|
15
|
-
JdbcColumn column)
|
16
|
-
{
|
17
|
-
super(batch, pageReader, column);
|
18
|
-
}
|
19
|
-
|
20
|
-
protected void booleanValue(boolean v) throws IOException, SQLException
|
21
|
-
{
|
22
|
-
batch.setDouble(v ? 1.0 : 0.0);
|
23
|
-
}
|
24
|
-
|
25
|
-
protected void longValue(long v) throws IOException, SQLException
|
26
|
-
{
|
27
|
-
batch.setDouble((double) v);
|
28
|
-
}
|
29
|
-
|
30
|
-
protected void doubleValue(double v) throws IOException, SQLException
|
31
|
-
{
|
32
|
-
batch.setDouble(v);
|
33
|
-
}
|
34
|
-
|
35
|
-
protected void stringValue(String v) throws IOException, SQLException
|
36
|
-
{
|
37
|
-
double dv;
|
38
|
-
try {
|
39
|
-
dv = Double.parseDouble(v);
|
40
|
-
} catch (NumberFormatException e) {
|
41
|
-
nullValue();
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
batch.setDouble(dv);
|
45
|
-
}
|
46
|
-
|
47
|
-
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
48
|
-
{
|
49
|
-
nullValue();
|
50
|
-
}
|
51
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.sql.SQLException;
|
5
|
+
import org.embulk.spi.ColumnVisitor;
|
6
|
+
import org.embulk.spi.PageReader;
|
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 DoubleColumnSetter
|
12
|
+
extends ColumnSetter
|
13
|
+
{
|
14
|
+
public DoubleColumnSetter(BatchInsert batch, PageReader pageReader,
|
15
|
+
JdbcColumn column)
|
16
|
+
{
|
17
|
+
super(batch, pageReader, column);
|
18
|
+
}
|
19
|
+
|
20
|
+
protected void booleanValue(boolean v) throws IOException, SQLException
|
21
|
+
{
|
22
|
+
batch.setDouble(v ? 1.0 : 0.0);
|
23
|
+
}
|
24
|
+
|
25
|
+
protected void longValue(long v) throws IOException, SQLException
|
26
|
+
{
|
27
|
+
batch.setDouble((double) v);
|
28
|
+
}
|
29
|
+
|
30
|
+
protected void doubleValue(double v) throws IOException, SQLException
|
31
|
+
{
|
32
|
+
batch.setDouble(v);
|
33
|
+
}
|
34
|
+
|
35
|
+
protected void stringValue(String v) throws IOException, SQLException
|
36
|
+
{
|
37
|
+
double dv;
|
38
|
+
try {
|
39
|
+
dv = Double.parseDouble(v);
|
40
|
+
} catch (NumberFormatException e) {
|
41
|
+
nullValue();
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
batch.setDouble(dv);
|
45
|
+
}
|
46
|
+
|
47
|
+
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
48
|
+
{
|
49
|
+
nullValue();
|
50
|
+
}
|
51
|
+
}
|
@@ -1,62 +1,62 @@
|
|
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.ColumnVisitor;
|
8
|
-
import org.embulk.spi.PageReader;
|
9
|
-
import org.embulk.spi.time.Timestamp;
|
10
|
-
import org.embulk.output.jdbc.JdbcColumn;
|
11
|
-
import org.embulk.output.jdbc.BatchInsert;
|
12
|
-
|
13
|
-
public class LongColumnSetter
|
14
|
-
extends ColumnSetter
|
15
|
-
{
|
16
|
-
public LongColumnSetter(BatchInsert batch, PageReader pageReader,
|
17
|
-
JdbcColumn column)
|
18
|
-
{
|
19
|
-
super(batch, pageReader, column);
|
20
|
-
}
|
21
|
-
|
22
|
-
protected void booleanValue(boolean v) throws IOException, SQLException
|
23
|
-
{
|
24
|
-
batch.setLong(v ? 1L : 0L);
|
25
|
-
}
|
26
|
-
|
27
|
-
protected void longValue(long v) throws IOException, SQLException
|
28
|
-
{
|
29
|
-
batch.setLong(v);
|
30
|
-
}
|
31
|
-
|
32
|
-
protected void doubleValue(double v) throws IOException, SQLException
|
33
|
-
{
|
34
|
-
long lv;
|
35
|
-
try {
|
36
|
-
// TODO configurable rounding mode
|
37
|
-
lv = DoubleMath.roundToLong(v, RoundingMode.HALF_UP);
|
38
|
-
} catch (ArithmeticException ex) {
|
39
|
-
// NaN / Infinite / -Infinite
|
40
|
-
nullValue();
|
41
|
-
return;
|
42
|
-
}
|
43
|
-
batch.setLong(lv);
|
44
|
-
}
|
45
|
-
|
46
|
-
protected void stringValue(String v) throws IOException, SQLException
|
47
|
-
{
|
48
|
-
long lv;
|
49
|
-
try {
|
50
|
-
lv = Long.parseLong(v);
|
51
|
-
} catch (NumberFormatException e) {
|
52
|
-
nullValue();
|
53
|
-
return;
|
54
|
-
}
|
55
|
-
batch.setLong(lv);
|
56
|
-
}
|
57
|
-
|
58
|
-
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
59
|
-
{
|
60
|
-
nullValue();
|
61
|
-
}
|
62
|
-
}
|
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.ColumnVisitor;
|
8
|
+
import org.embulk.spi.PageReader;
|
9
|
+
import org.embulk.spi.time.Timestamp;
|
10
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
11
|
+
import org.embulk.output.jdbc.BatchInsert;
|
12
|
+
|
13
|
+
public class LongColumnSetter
|
14
|
+
extends ColumnSetter
|
15
|
+
{
|
16
|
+
public LongColumnSetter(BatchInsert batch, PageReader pageReader,
|
17
|
+
JdbcColumn column)
|
18
|
+
{
|
19
|
+
super(batch, pageReader, column);
|
20
|
+
}
|
21
|
+
|
22
|
+
protected void booleanValue(boolean v) throws IOException, SQLException
|
23
|
+
{
|
24
|
+
batch.setLong(v ? 1L : 0L);
|
25
|
+
}
|
26
|
+
|
27
|
+
protected void longValue(long v) throws IOException, SQLException
|
28
|
+
{
|
29
|
+
batch.setLong(v);
|
30
|
+
}
|
31
|
+
|
32
|
+
protected void doubleValue(double v) throws IOException, SQLException
|
33
|
+
{
|
34
|
+
long lv;
|
35
|
+
try {
|
36
|
+
// TODO configurable rounding mode
|
37
|
+
lv = DoubleMath.roundToLong(v, RoundingMode.HALF_UP);
|
38
|
+
} catch (ArithmeticException ex) {
|
39
|
+
// NaN / Infinite / -Infinite
|
40
|
+
nullValue();
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
batch.setLong(lv);
|
44
|
+
}
|
45
|
+
|
46
|
+
protected void stringValue(String v) throws IOException, SQLException
|
47
|
+
{
|
48
|
+
long lv;
|
49
|
+
try {
|
50
|
+
lv = Long.parseLong(v);
|
51
|
+
} catch (NumberFormatException e) {
|
52
|
+
nullValue();
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
batch.setLong(lv);
|
56
|
+
}
|
57
|
+
|
58
|
+
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
59
|
+
{
|
60
|
+
nullValue();
|
61
|
+
}
|
62
|
+
}
|
@@ -1,43 +1,43 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import java.io.IOException;
|
4
|
-
import java.sql.SQLException;
|
5
|
-
import org.embulk.spi.PageReader;
|
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 NullColumnSetter
|
11
|
-
extends ColumnSetter
|
12
|
-
{
|
13
|
-
public NullColumnSetter(BatchInsert batch, PageReader pageReader,
|
14
|
-
JdbcColumn column)
|
15
|
-
{
|
16
|
-
super(batch, pageReader, column);
|
17
|
-
}
|
18
|
-
|
19
|
-
protected void booleanValue(boolean v) throws IOException, SQLException
|
20
|
-
{
|
21
|
-
nullValue();
|
22
|
-
}
|
23
|
-
|
24
|
-
protected void longValue(long v) throws IOException, SQLException
|
25
|
-
{
|
26
|
-
nullValue();
|
27
|
-
}
|
28
|
-
|
29
|
-
protected void doubleValue(double v) throws IOException, SQLException
|
30
|
-
{
|
31
|
-
nullValue();
|
32
|
-
}
|
33
|
-
|
34
|
-
protected void stringValue(String v) throws IOException, SQLException
|
35
|
-
{
|
36
|
-
nullValue();
|
37
|
-
}
|
38
|
-
|
39
|
-
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
40
|
-
{
|
41
|
-
nullValue();
|
42
|
-
}
|
43
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
import java.sql.SQLException;
|
5
|
+
import org.embulk.spi.PageReader;
|
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 NullColumnSetter
|
11
|
+
extends ColumnSetter
|
12
|
+
{
|
13
|
+
public NullColumnSetter(BatchInsert batch, PageReader pageReader,
|
14
|
+
JdbcColumn column)
|
15
|
+
{
|
16
|
+
super(batch, pageReader, column);
|
17
|
+
}
|
18
|
+
|
19
|
+
protected void booleanValue(boolean v) throws IOException, SQLException
|
20
|
+
{
|
21
|
+
nullValue();
|
22
|
+
}
|
23
|
+
|
24
|
+
protected void longValue(long v) throws IOException, SQLException
|
25
|
+
{
|
26
|
+
nullValue();
|
27
|
+
}
|
28
|
+
|
29
|
+
protected void doubleValue(double v) throws IOException, SQLException
|
30
|
+
{
|
31
|
+
nullValue();
|
32
|
+
}
|
33
|
+
|
34
|
+
protected void stringValue(String v) throws IOException, SQLException
|
35
|
+
{
|
36
|
+
nullValue();
|
37
|
+
}
|
38
|
+
|
39
|
+
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
40
|
+
{
|
41
|
+
nullValue();
|
42
|
+
}
|
43
|
+
}
|
@@ -1,38 +1,38 @@
|
|
1
|
-
package org.embulk.output.jdbc.setter;
|
2
|
-
|
3
|
-
import org.embulk.spi.PageReader;
|
4
|
-
import org.embulk.spi.time.Timestamp;
|
5
|
-
import org.embulk.output.jdbc.BatchInsert;
|
6
|
-
|
7
|
-
public class SkipColumnSetter
|
8
|
-
extends ColumnSetter
|
9
|
-
{
|
10
|
-
public SkipColumnSetter(BatchInsert batch, PageReader pageReader)
|
11
|
-
{
|
12
|
-
super(batch, pageReader, null);
|
13
|
-
}
|
14
|
-
|
15
|
-
protected void booleanValue(boolean v)
|
16
|
-
{
|
17
|
-
}
|
18
|
-
|
19
|
-
protected void longValue(long v)
|
20
|
-
{
|
21
|
-
}
|
22
|
-
|
23
|
-
protected void doubleValue(double v)
|
24
|
-
{
|
25
|
-
}
|
26
|
-
|
27
|
-
protected void stringValue(String v)
|
28
|
-
{
|
29
|
-
}
|
30
|
-
|
31
|
-
protected void timestampValue(Timestamp v)
|
32
|
-
{
|
33
|
-
}
|
34
|
-
|
35
|
-
protected void nullValue()
|
36
|
-
{
|
37
|
-
}
|
38
|
-
}
|
1
|
+
package org.embulk.output.jdbc.setter;
|
2
|
+
|
3
|
+
import org.embulk.spi.PageReader;
|
4
|
+
import org.embulk.spi.time.Timestamp;
|
5
|
+
import org.embulk.output.jdbc.BatchInsert;
|
6
|
+
|
7
|
+
public class SkipColumnSetter
|
8
|
+
extends ColumnSetter
|
9
|
+
{
|
10
|
+
public SkipColumnSetter(BatchInsert batch, PageReader pageReader)
|
11
|
+
{
|
12
|
+
super(batch, pageReader, null);
|
13
|
+
}
|
14
|
+
|
15
|
+
protected void booleanValue(boolean v)
|
16
|
+
{
|
17
|
+
}
|
18
|
+
|
19
|
+
protected void longValue(long v)
|
20
|
+
{
|
21
|
+
}
|
22
|
+
|
23
|
+
protected void doubleValue(double v)
|
24
|
+
{
|
25
|
+
}
|
26
|
+
|
27
|
+
protected void stringValue(String v)
|
28
|
+
{
|
29
|
+
}
|
30
|
+
|
31
|
+
protected void timestampValue(Timestamp v)
|
32
|
+
{
|
33
|
+
}
|
34
|
+
|
35
|
+
protected void nullValue()
|
36
|
+
{
|
37
|
+
}
|
38
|
+
}
|
@@ -1,48 +1,48 @@
|
|
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.PageReader;
|
8
|
-
import org.embulk.spi.time.Timestamp;
|
9
|
-
import org.embulk.output.jdbc.JdbcColumn;
|
10
|
-
import org.embulk.output.jdbc.BatchInsert;
|
11
|
-
|
12
|
-
public class SqlTimestampColumnSetter
|
13
|
-
extends ColumnSetter
|
14
|
-
{
|
15
|
-
public SqlTimestampColumnSetter(BatchInsert batch, PageReader pageReader,
|
16
|
-
JdbcColumn column)
|
17
|
-
{
|
18
|
-
super(batch, pageReader, column);
|
19
|
-
}
|
20
|
-
|
21
|
-
protected void booleanValue(boolean v) throws IOException, SQLException
|
22
|
-
{
|
23
|
-
nullValue();
|
24
|
-
}
|
25
|
-
|
26
|
-
protected void longValue(long v) throws IOException, SQLException
|
27
|
-
{
|
28
|
-
nullValue();
|
29
|
-
}
|
30
|
-
|
31
|
-
protected void doubleValue(double v) throws IOException, SQLException
|
32
|
-
{
|
33
|
-
nullValue();
|
34
|
-
}
|
35
|
-
|
36
|
-
protected void stringValue(String v) throws IOException, SQLException
|
37
|
-
{
|
38
|
-
// TODO parse time?
|
39
|
-
nullValue();
|
40
|
-
}
|
41
|
-
|
42
|
-
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
43
|
-
{
|
44
|
-
java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli());
|
45
|
-
t.setNanos(v.getNano());
|
46
|
-
batch.setSqlTimestamp(t, getSqlType());
|
47
|
-
}
|
48
|
-
}
|
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.PageReader;
|
8
|
+
import org.embulk.spi.time.Timestamp;
|
9
|
+
import org.embulk.output.jdbc.JdbcColumn;
|
10
|
+
import org.embulk.output.jdbc.BatchInsert;
|
11
|
+
|
12
|
+
public class SqlTimestampColumnSetter
|
13
|
+
extends ColumnSetter
|
14
|
+
{
|
15
|
+
public SqlTimestampColumnSetter(BatchInsert batch, PageReader pageReader,
|
16
|
+
JdbcColumn column)
|
17
|
+
{
|
18
|
+
super(batch, pageReader, column);
|
19
|
+
}
|
20
|
+
|
21
|
+
protected void booleanValue(boolean v) throws IOException, SQLException
|
22
|
+
{
|
23
|
+
nullValue();
|
24
|
+
}
|
25
|
+
|
26
|
+
protected void longValue(long v) throws IOException, SQLException
|
27
|
+
{
|
28
|
+
nullValue();
|
29
|
+
}
|
30
|
+
|
31
|
+
protected void doubleValue(double v) throws IOException, SQLException
|
32
|
+
{
|
33
|
+
nullValue();
|
34
|
+
}
|
35
|
+
|
36
|
+
protected void stringValue(String v) throws IOException, SQLException
|
37
|
+
{
|
38
|
+
// TODO parse time?
|
39
|
+
nullValue();
|
40
|
+
}
|
41
|
+
|
42
|
+
protected void timestampValue(Timestamp v) throws IOException, SQLException
|
43
|
+
{
|
44
|
+
java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli());
|
45
|
+
t.setNanos(v.getNano());
|
46
|
+
batch.setSqlTimestamp(t, getSqlType());
|
47
|
+
}
|
48
|
+
}
|