diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/BatchInsert.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/BatchInsert.java index 6dc631f1..edb3d1b7 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/BatchInsert.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/BatchInsert.java @@ -4,7 +4,7 @@ import java.util.Calendar; import java.io.IOException; import java.sql.SQLException; -import org.embulk.spi.time.Timestamp; +import java.time.Instant; public interface BatchInsert { @@ -47,9 +47,9 @@ public interface BatchInsert public void setBytes(byte[] v) throws IOException, SQLException; - public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLException; + public void setSqlDate(Instant v, Calendar cal) throws IOException, SQLException; - public void setSqlTime(Timestamp v, Calendar cal) throws IOException, SQLException; + public void setSqlTime(Instant v, Calendar cal) throws IOException, SQLException; - public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException, SQLException; + public void setSqlTimestamp(Instant v, Calendar cal) throws IOException, SQLException; } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/MemoryRecord.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/MemoryRecord.java index e04c46ef..92c0dbb7 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/MemoryRecord.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/MemoryRecord.java @@ -1,10 +1,9 @@ package org.embulk.output.jdbc; +import java.time.Instant; import org.embulk.spi.Column; -import org.embulk.spi.time.Timestamp; import org.msgpack.value.Value; - public class MemoryRecord implements Record { private final Object[] values; @@ -40,9 +39,9 @@ public String getString(Column column) return (String)getValue(column); } - public Timestamp getTimestamp(Column column) + public Instant getTimestamp(Column column) { - return (Timestamp)getValue(column); + return ((org.embulk.spi.time.Timestamp) getValue(column)).getInstant(); } public Value getJson(Column column) @@ -60,4 +59,3 @@ public void setValue(Column column, Object value) values[column.getIndex()] = value; } } - diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/PageReaderRecord.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/PageReaderRecord.java index f736c5a4..713211c1 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/PageReaderRecord.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/PageReaderRecord.java @@ -1,15 +1,14 @@ package org.embulk.output.jdbc; +import java.time.Instant; import java.util.ArrayList; import java.util.List; import org.embulk.spi.Column; import org.embulk.spi.Page; import org.embulk.spi.PageReader; -import org.embulk.spi.time.Timestamp; import org.msgpack.value.Value; - /** * Record read by PageReader. * The class will save read records for retry. @@ -62,9 +61,9 @@ public String getString(Column column) return save(column, pageReader.getString(column)); } - public Timestamp getTimestamp(Column column) + public Instant getTimestamp(Column column) { - return save(column, pageReader.getTimestamp(column)); + return save(column, pageReader.getTimestamp(column).getInstant()); } public Value getJson(Column column) @@ -93,4 +92,3 @@ private T save(Column column, T value) return value; } } - diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/Record.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/Record.java index bb592399..5ff55359 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/Record.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/Record.java @@ -1,7 +1,7 @@ package org.embulk.output.jdbc; +import java.time.Instant; import org.embulk.spi.Column; -import org.embulk.spi.time.Timestamp; import org.msgpack.value.Value; public interface Record @@ -16,8 +16,7 @@ public interface Record String getString(Column column); - Timestamp getTimestamp(Column column); + Instant getTimestamp(Column column); Value getJson(Column column); } - diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java index c4b5c371..de3f2c3b 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/StandardBatchInsert.java @@ -8,10 +8,10 @@ import java.sql.SQLException; import java.sql.Date; import java.sql.Time; +import java.time.Instant; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.embulk.spi.time.Timestamp; public class StandardBatchInsert implements BatchInsert @@ -184,7 +184,7 @@ public void setBytes(byte[] v) throws IOException, SQLException nextColumn(v.length + 4); } - public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlDate(final Instant v, final Calendar cal) throws IOException, SQLException { // JavaDoc of java.sql.Time says: // >> To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated. @@ -197,14 +197,14 @@ public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLExcepti nextColumn(32); } - public void setSqlTime(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlTime(final Instant v, final Calendar cal) throws IOException, SQLException { Time t = new Time(v.toEpochMilli()); batch.setTime(index, t, cal); nextColumn(32); } - public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlTimestamp(final Instant v, final Calendar cal) throws IOException, SQLException { java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli()); t.setNanos(v.getNano()); diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java index 82895cb3..b042c332 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BigDecimalColumnSetter.java @@ -3,8 +3,8 @@ import java.math.BigDecimal; import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -63,7 +63,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setBigDecimal(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java index 4633fb23..bae111d5 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/BooleanColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -48,7 +48,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setBoolean(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java index cfcb4c19..5f1c842c 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ByteColumnSetter.java @@ -3,10 +3,10 @@ import java.io.IOException; import java.sql.SQLException; import java.math.RoundingMode; +import java.time.Instant; import com.google.common.math.DoubleMath; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -71,7 +71,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setByte(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java index 96327e68..a00339b2 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ColumnSetter.java @@ -2,10 +2,10 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; import org.embulk.output.jdbc.BatchInsert; import org.embulk.output.jdbc.JdbcColumn; -import org.embulk.spi.time.Timestamp; import org.msgpack.value.Value; public abstract class ColumnSetter @@ -42,7 +42,7 @@ public int getSqlType() public abstract void stringValue(String v) throws IOException, SQLException; - public abstract void timestampValue(Timestamp v) throws IOException, SQLException; + public abstract void timestampValue(final Instant v) throws IOException, SQLException; public abstract void jsonValue(Value v) throws IOException, SQLException; } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java index c84b84eb..d74ef7e8 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/DoubleColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -55,7 +55,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setDouble(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java index 784540a2..03ef7bf7 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/FloatColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -55,7 +55,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setFloat(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java index 063c87f5..8af10fc6 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/IntColumnSetter.java @@ -3,10 +3,10 @@ import java.io.IOException; import java.sql.SQLException; import java.math.RoundingMode; +import java.time.Instant; import com.google.common.math.DoubleMath; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -71,7 +71,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setInt(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/JsonColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/JsonColumnSetter.java index 6c93375f..d1645aab 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/JsonColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/JsonColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -48,7 +48,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setJson(); } @@ -58,4 +58,3 @@ public void jsonValue(Value v) throws IOException, SQLException { batch.setString(v.toJson()); } } - diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java index d0fdd8b6..4254e6ec 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/LongColumnSetter.java @@ -3,10 +3,10 @@ import java.io.IOException; import java.sql.SQLException; import java.math.RoundingMode; +import java.time.Instant; import com.google.common.math.DoubleMath; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -67,7 +67,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setLong(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java index ea8ceacf..1138f95c 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NStringColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.embulk.util.timestamp.TimestampFormatter; @@ -53,9 +53,9 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { - batch.setNString(timestampFormatter.format(v.getInstant())); + batch.setNString(timestampFormatter.format(v)); } @Override diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java index 80f19378..2833de19 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/NullColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -42,7 +42,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setNull(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java index c5673ab7..c81ee815 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/PassThroughColumnSetter.java @@ -3,8 +3,8 @@ import java.util.Calendar; import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -53,7 +53,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { batch.setSqlTimestamp(v, calendar); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ShortColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ShortColumnSetter.java index 1b8cd4a5..5fd948e8 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ShortColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/ShortColumnSetter.java @@ -3,10 +3,10 @@ import java.io.IOException; import java.sql.SQLException; import java.math.RoundingMode; +import java.time.Instant; import com.google.common.math.DoubleMath; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -71,7 +71,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { defaultValue.setShort(); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java index 9a7a127f..173d2111 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SkipColumnSetter.java @@ -1,6 +1,6 @@ package org.embulk.output.jdbc.setter; -import org.embulk.spi.time.Timestamp; +import java.time.Instant; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -33,7 +33,7 @@ public void stringValue(String v) } @Override - public void timestampValue(Timestamp v) + public void timestampValue(final Instant v) { } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlDateColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlDateColumnSetter.java index 8b0a0a0a..5219e5d7 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlDateColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlDateColumnSetter.java @@ -3,8 +3,8 @@ import java.util.Calendar; import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -53,7 +53,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { batch.setSqlDate(v, calendar); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimeColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimeColumnSetter.java index 188b264c..12575dda 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimeColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimeColumnSetter.java @@ -3,8 +3,8 @@ import java.util.Calendar; import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -53,7 +53,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { batch.setSqlTime(v, calendar); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java index b2ffc816..6f885f8c 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/SqlTimestampColumnSetter.java @@ -3,8 +3,8 @@ import java.util.Calendar; import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.msgpack.value.Value; @@ -53,7 +53,7 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { batch.setSqlTimestamp(v, calendar); } diff --git a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java index 9a2aa41c..9478dc4c 100644 --- a/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java +++ b/embulk-output-jdbc/src/main/java/org/embulk/output/jdbc/setter/StringColumnSetter.java @@ -2,8 +2,8 @@ import java.io.IOException; import java.sql.SQLException; +import java.time.Instant; -import org.embulk.spi.time.Timestamp; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.BatchInsert; import org.embulk.util.timestamp.TimestampFormatter; @@ -53,9 +53,9 @@ public void stringValue(String v) throws IOException, SQLException } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { - batch.setString(timestampFormatter.format(v.getInstant())); + batch.setString(timestampFormatter.format(v)); } @Override diff --git a/embulk-output-oracle/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java b/embulk-output-oracle/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java index 9ae870f4..49943378 100644 --- a/embulk-output-oracle/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java +++ b/embulk-output-oracle/src/main/java/org/embulk/output/oracle/DirectBatchInsert.java @@ -6,6 +6,7 @@ import java.sql.Types; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; @@ -22,7 +23,6 @@ import org.embulk.output.oracle.oci.OCIWrapper; import org.embulk.output.oracle.oci.RowBuffer; import org.embulk.output.oracle.oci.TableDefinition; -import org.embulk.spi.time.Timestamp; public class DirectBatchInsert implements BatchInsert { @@ -260,19 +260,19 @@ public void setBytes(byte[] v) throws IOException, SQLException } @Override - public void setSqlDate(Timestamp v, Calendar calendar) throws IOException, SQLException + public void setSqlDate(final Instant v, final Calendar calendar) throws IOException, SQLException { throw new SQLException("Unsupported"); } @Override - public void setSqlTime(Timestamp v, Calendar calendar) throws IOException, SQLException + public void setSqlTime(final Instant v, final Calendar calendar) throws IOException, SQLException { throw new SQLException("Unsupported"); } @Override - public void setSqlTimestamp(Timestamp v, Calendar calendar) throws IOException, SQLException + public void setSqlTimestamp(final Instant v, final Calendar calendar) throws IOException, SQLException { java.sql.Timestamp t = new java.sql.Timestamp(v.toEpochMilli()); t.setNanos(v.getNano()); diff --git a/embulk-output-postgresql/src/main/java/org/embulk/output/postgresql/AbstractPostgreSQLCopyBatchInsert.java b/embulk-output-postgresql/src/main/java/org/embulk/output/postgresql/AbstractPostgreSQLCopyBatchInsert.java index 083ffd22..80c1cb33 100644 --- a/embulk-output-postgresql/src/main/java/org/embulk/output/postgresql/AbstractPostgreSQLCopyBatchInsert.java +++ b/embulk-output-postgresql/src/main/java/org/embulk/output/postgresql/AbstractPostgreSQLCopyBatchInsert.java @@ -9,7 +9,7 @@ import java.io.IOException; import java.nio.charset.Charset; import java.math.BigDecimal; -import org.embulk.spi.time.Timestamp; +import java.time.Instant; import org.embulk.output.jdbc.BatchInsert; public abstract class AbstractPostgreSQLCopyBatchInsert @@ -157,7 +157,7 @@ public void setBytes(byte[] v) throws IOException setEscapedString(String.valueOf(v)); } - public void setSqlDate(Timestamp v, Calendar cal) throws IOException + public void setSqlDate(final Instant v, final Calendar cal) throws IOException { appendDelimiter(); cal.setTimeInMillis(v.getEpochSecond() * 1000); @@ -168,7 +168,7 @@ public void setSqlDate(Timestamp v, Calendar cal) throws IOException writer.write(f); } - public void setSqlTime(Timestamp v, Calendar cal) throws IOException + public void setSqlTime(final Instant v, final Calendar cal) throws IOException { appendDelimiter(); cal.setTimeInMillis(v.getEpochSecond() * 1000); @@ -180,7 +180,7 @@ public void setSqlTime(Timestamp v, Calendar cal) throws IOException writer.write(f); } - public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException + public void setSqlTimestamp(final Instant v, final Calendar cal) throws IOException { appendDelimiter(); cal.setTimeInMillis(v.getEpochSecond() * 1000); diff --git a/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/NativeBatchInsert.java b/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/NativeBatchInsert.java index efcb2038..c8917021 100644 --- a/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/NativeBatchInsert.java +++ b/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/NativeBatchInsert.java @@ -6,6 +6,7 @@ import java.sql.Types; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.Calendar; import java.util.Optional; @@ -16,7 +17,6 @@ import org.embulk.output.jdbc.TableIdentifier; import org.embulk.output.jdbc.TimestampFormat; import org.embulk.output.sqlserver.nativeclient.NativeClientWrapper; -import org.embulk.spi.time.Timestamp; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -192,19 +192,19 @@ public void setBytes(byte[] v) throws IOException, SQLException } @Override - public void setSqlDate(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlDate(final Instant v, final Calendar cal) throws IOException, SQLException { setSqlTimestamp(v, cal); } @Override - public void setSqlTime(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlTime(final Instant v, final Calendar cal) throws IOException, SQLException { setSqlTimestamp(v, cal); } @Override - public void setSqlTimestamp(Timestamp v, Calendar cal) throws IOException, SQLException + public void setSqlTimestamp(final Instant v, final Calendar cal) throws IOException, SQLException { int columnIndex = nextColumnIndex(); DateFormat format = formats[columnIndex - 1]; diff --git a/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java b/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java index df253870..77a27b92 100644 --- a/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java +++ b/embulk-output-sqlserver/src/main/java/org/embulk/output/sqlserver/setter/SQLServerSqlTimeColumnSetter.java @@ -3,12 +3,12 @@ import java.io.IOException; import java.sql.SQLException; import java.util.Calendar; +import java.time.Instant; import org.embulk.output.jdbc.BatchInsert; import org.embulk.output.jdbc.JdbcColumn; import org.embulk.output.jdbc.setter.DefaultValueSetter; import org.embulk.output.jdbc.setter.SqlTimeColumnSetter; -import org.embulk.spi.time.Timestamp; public class SQLServerSqlTimeColumnSetter extends SqlTimeColumnSetter @@ -21,7 +21,7 @@ public SQLServerSqlTimeColumnSetter(BatchInsert batch, JdbcColumn column, } @Override - public void timestampValue(Timestamp v) throws IOException, SQLException + public void timestampValue(final Instant v) throws IOException, SQLException { // fractional precision of SQLServer TIME is 7, but that of java.sql.Time is only 3. batch.setSqlTimestamp(v, calendar);