提交 72be2bd2 authored 作者: Philippe Marschall's avatar Philippe Marschall

Fix JDBC type of TIMESTAMP WITH TIME ZONE

Currently the JDBC type of TIMESTAMP WITH TIME ZONE is Types.OTHER.
JDBC 4.2 has a dedicated type for this Types.TIMESTAMP_WITH_TIMEZONE.

Unfortunately this type is only available in JDBC 4.2/Java 1.8 so I
hard code the constant value instead of the constant reference.
上级 079c91bf
...@@ -21,6 +21,9 @@ Change Log ...@@ -21,6 +21,9 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li><strong>[API CHANGE]</strong> #439: the JDBC type of TIMESTAMP WITH TIME ZONE
changed from Types.OTHER (1111) to Types.TIMESTAMP_WITH_TIMEZONE (2014)
</li>
<li>#430: Subquery not cached if number of rows exceeds MAX_MEMORY_ROWS <li>#430: Subquery not cached if number of rows exceeds MAX_MEMORY_ROWS
</li> </li>
<li>#411: "TIMEZONE" should be "TIME ZONE" in type "TIMESTAMP WITH TIMEZONE" <li>#411: "TIMEZONE" should be "TIME ZONE" in type "TIMESTAMP WITH TIMEZONE"
......
...@@ -315,7 +315,11 @@ public class DataType { ...@@ -315,7 +315,11 @@ public class DataType {
// 24 for ValueTimestamp, 32 for java.sql.Timestamp // 24 for ValueTimestamp, 32 for java.sql.Timestamp
56 56
); );
add(Value.TIMESTAMP_TZ, Types.OTHER, "TimestampTimeZone", // 2014 is the value of Types.TIMESTAMP_WITH_TIMEZONE
// use the value instead of the reference because the code has to compile
// on Java 1.7
// can be replaced with Types.TIMESTAMP_WITH_TIMEZONE once Java 1.8 is required
add(Value.TIMESTAMP_TZ, 2014, "TimestampTimeZone",
createDate(ValueTimestampTimeZone.PRECISION, "TIMESTAMP_TZ", createDate(ValueTimestampTimeZone.PRECISION, "TIMESTAMP_TZ",
ValueTimestampTimeZone.DEFAULT_SCALE, ValueTimestampTimeZone.DISPLAY_SIZE), ValueTimestampTimeZone.DEFAULT_SCALE, ValueTimestampTimeZone.DISPLAY_SIZE),
new String[]{"TIMESTAMP WITH TIME ZONE"}, new String[]{"TIMESTAMP WITH TIME ZONE"},
......
...@@ -7,6 +7,7 @@ package org.h2.test.unit; ...@@ -7,6 +7,7 @@ package org.h2.test.unit;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.api.TimestampWithTimeZone; import org.h2.api.TimestampWithTimeZone;
...@@ -102,6 +103,15 @@ public class TestTimeStampWithTimeZone extends TestBase { ...@@ -102,6 +103,15 @@ public class TestTimeStampWithTimeZone extends TestBase {
assertEquals("2015-12-31T19:00-10:00", rs.getObject(1, assertEquals("2015-12-31T19:00-10:00", rs.getObject(1,
LocalDateTimeUtils.getOffsetDateTimeClass()).toString()); LocalDateTimeUtils.getOffsetDateTimeClass()).toString());
} }
ResultSetMetaData metaData = rs.getMetaData();
int columnType = metaData.getColumnType(1);
// 2014 is the value of Types.TIMESTAMP_WITH_TIMEZONE
// use the value instead of the reference because the code has to compile
// on Java 1.7
// can be replaced with Types.TIMESTAMP_WITH_TIMEZONE once Java 1.8 is required
assertEquals(2014, columnType);
rs.close(); rs.close();
stat.close(); stat.close();
conn.close(); conn.close();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论