在编写 Java 日期之前SQL TIMESTAMP 列,JDBC 将 Java 虚拟机时区的日期转换为数据库会话的日期?
Before writing a Java Date to an SQL TIMESTAMP column, does JDBC translate the date from the Java virtual machine time zone to that of the database session?
例如,假设 Java 虚拟机时区是 UTC 并且数据库会话时区是 UTC-5.如果 Java 程序尝试通过将 2000-01-01 00:00:00 传递给 PreparedStatement#setTimestamp(int, Timestamp),根据JDBC标准,数据库会存储TIMESTAMP '2000-01-01 00:00:00'还是TIMESTAMP '1999-12-31 19:00:00'?
For example, suppose the Java virtual machine time zone is UTC and the database session time zone is UTC-5. If a Java program attempts to store 2000-01-01 00:00:00 by passing it to PreparedStatement#setTimestamp(int, Timestamp), according to the JDBC standard, will the database store TIMESTAMP '2000-01-01 00:00:00' or TIMESTAMP '1999-12-31 19:00:00'?
不,JDBC 只是一个关于如何使用的 API客户端可以访问数据库.对于时间戳存储,这必须取决于编写符合 JDBC API 标准的数据库驱动程序的组织.
No, JDBC is just an API on how the client can access the database. For timestamp storage, this will have to be dependent by the organisation that writes their database drivers that conforms to the JDBC API standard.
这里一个MySQL实现PreparedStatement的实现.他们似乎将 Java 的 JVM 时区带到了 MySQL 时区(检查 setTimestampInternal() 方法).
Here's an implementation of MySQL's implementation of PreparedStatement. They seem to take Java's JVM timezone to MySQL Timezone (check the setTimestampInternal() method).
这篇关于在将 Java 日期写入 SQL TIMESTAMP 列之前,JDBC 是否会将日期从 JVM 时区转换为数据库会话时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
“Char 不能被取消引用"错误quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用错误)
Java Switch 语句 - 是“或"/“和"可能的?Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 语句 - 是“或/“和可能的?)
Java替换字符串特定位置的字符?Java Replace Character At Specific Position Of String?(Java替换字符串特定位置的字符?)
具有 int 和 char 操作数的三元表达式的类型是什么What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作数的三元表达式的类型是什么?)
读取文本文件并存储出现的每个字符Read a text file and store every single character occurrence(读取文本文件并存储出现的每个字符)
为什么我需要在 byte 和 short 上显式转换 char 原语Why do I need to explicitly cast char primitives on byte and short?(为什么我需要在 byte 和 short 上显式转换 char 原语?)