For this PostgreSQL test table:
CREATE TABLE public.test (
id BIGSERIAL,
"datetime" TIMESTAMP WITHOUT TIME ZONE DEFAULT now(),
value INTEGER,
CONSTRAINT test_pkey PRIMARY KEY(id)
)
I am using this SQL insert:
INSERT INTO it.test (value) VALUES (1);
No problem when I execute the INSERT from a remote client like EMS or PgAdmin. The field datetime is populated with the server timestamp exactly, but when I execute the INSERT from a Java program using Postgres/JDBC Driver (postgresql-9.2-1002.jdbc4.jar), the field datetime is populated with a timestamp different to the server.
I read that the JVM use the local PC time zone. There is any way to avoid this?
If I change the datatype from timestamp to timestampz, java populate the field with the server timestamp, but I want solve it without change the datatype, because the table is used by another programs and reports.