X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 9F6639DCA09 for ; Wed, 25 Jan 2006 14:46:04 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41615-06 for ; Wed, 25 Jan 2006 14:46:03 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from uproxy.gmail.com (uproxy.gmail.com [66.249.92.194]) by postgresql.org (Postfix) with ESMTP id 2D2959DCA47 for ; Wed, 25 Jan 2006 14:45:59 -0400 (AST) Received: by uproxy.gmail.com with SMTP id s2so300927uge for ; Wed, 25 Jan 2006 10:45:59 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; b=SLP82Ta24qVg4QzPvngf7vy8il7eHgLle/9puCKYRv+bUvD1YmyO8UU4j2ixEZuU5bcg8Da7AwL3kJT+aY887sudWwm29snlhoy4jhazSMeg1eXvtTI7zYMuc8dF1d27zuHowKToOROHj7UWeq0GS8BftH6yw3IDWgdSzEV8U/8= Received: by 10.67.31.14 with SMTP id i14mr456838ugj; Wed, 25 Jan 2006 10:45:59 -0800 (PST) Received: by 10.66.249.20 with HTTP; Wed, 25 Jan 2006 10:45:59 -0800 (PST) Message-ID: <91d5bf2c0601251045p5f5d5b6fp405c30b513cbdc6a@mail.gmail.com> Date: Wed, 25 Jan 2006 15:45:59 -0300 From: Lucas Sanabio Reply-To: lucas@marx.com.br To: pgsql-jdbc@postgresql.org Subject: Inserting the wrong date MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_56492_17057505.1138214759037" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.333 required=5 tests=[HTML_MESSAGE=0.001, RCVD_IN_BL_SPAMCOP_NET=1.332] X-Spam-Score: 1.333 X-Spam-Level: * X-Archive-Number: 200601/114 X-Sequence-Number: 14565 ------=_Part_56492_17057505.1138214759037 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi everyone! I'm having an problem when I try to insert data into a timestamp field, let me try to explain what is going in on. I developed my application at my local machine and at this machine everything is working as it should, but when I deployed the application int= o the production server, every time I save an timestamp it saves it one hour before. The method that is inserting the data is pasted below: ############################ public int inserir(CompromissoVO vo, Connection conn) throws Exception { PreparedStatement stp =3D null; int chave =3D 0; final String sql =3D "INSERT INTO " + ESQUEMA + ".compromisso (com_id, com_criacao, com_data, " + "com_titulo, com_confidencial, tco_id, com_agendamento, aud_id, " + "via_id, soe_id)" + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; try { chave =3D ConnectionManager.getSequence("comp_seq"); int i =3D 1; stp =3D conn.prepareStatement(sql); stp.setInt(i++, chave); Date agora =3D new Date(); stp.setTimestamp(i++, new Timestamp(agora.getTime())); SimpleDateFormat sd =3D new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); log.debug("Inserir - Data compromisso: " + sd.format(vo.getData ())); stp.setTimestamp(i++, new Timestamp(vo.getData().getTime())); stp.setString(i++, vo.getTitulo()); stp.setString(i++, vo.getConfidencial()); stp.setInt(i++, vo.getTipo().getCodigo()); stp.setString(i++, vo.getTipoAgendamento()); if (vo.getAudiencia() > 0){ stp.setInt(i++, vo.getAudiencia()); } else { stp.setNull(i++, Types.INTEGER); } if (vo.getViagem() > 0){ stp.setInt(i++, vo.getViagem()); } else { stp.setNull(i++, Types.INTEGER); } if (vo.getSolenidade() > 0){ stp.setInt(i++, vo.getSolenidade()); } else { stp.setNull(i++, Types.INTEGER); } stp.execute(); } catch (NegocioException ne) { throw ne; } catch (Exception e) { log.debug("sql: " + sql); throw new NegocioException("error.inserir.compromisso", e); } return chave; } ############################ The vo.getData() return the date which was typed by the user, I logged the date to see if it was right and I got it was, but when I look at the database the date is one hour before. Log: 2006-01-25 16:05:08,877 -> DEBUG (CompromissoDAO.java:140) - Alterar - Data compromisso: 12/01/2006 12:00:00 The data which was saved at the database: 2006-01-12 11:00:00 My table script is: CREATE TABLE compromisso ( com_id numeric(6) NOT NULL, com_criacao timestamp NOT NULL, com_data timestamp NOT NULL, com_titulo varchar(200) NOT NULL, com_confidencial varchar(400), com_agendamento char(1), tco_id numeric(6) NOT NULL, aud_id numeric(6), via_id numeric(6), soe_id numeric(6), CONSTRAINT compromisso_pk PRIMARY KEY (com_id), CONSTRAINT com_tipocompromisso_fk FOREIGN KEY (tco_id) REFERENCES compromisso_tipo (tco_id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT compromisso_audiencia_fk FOREIGN KEY (aud_id) REFERENCES registro_audiencia (aud_id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT compromisso_solenidade_fk FOREIGN KEY (soe_id) REFERENCES registro_solenidade (soe_id) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT compromisso_viagem_fk FOREIGN KEY (via_id) REFERENCES registro_viagem (via_id) ON UPDATE RESTRICT ON DELETE RESTRICT ) WITHOUT OIDS; ALTER TABLE compromisso OWNER TO uzzi; GRANT ALL ON TABLE compromisso TO uzzi; Does any one have an idea what is going in on? Thanks, -- Lucas Sanabio ---------------------------------------------------------------------------= -- Sun Certified Programmer for the Java 2 Platform Consultor Java - Marx Tecnologia Email: lucas@marx.com.br Cel: (61) 8402-8876 ------=_Part_56492_17057505.1138214759037 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi everyone! I'm having an problem when I try to insert data into a timesta= mp field, let me try to explain what is going in on.

I developed my application at my local machine and at this machine everything is working as it should, but when I deployed the application into the production server, every time I save an timestamp it saves it one hour before. The method that is inserting the data is pasted below:

############################
public int inserir(CompromissoVO vo, Connection conn) throws Exception {         PreparedStatement stp =3D null;

        int chave =3D 0;

        final String sql =3D "INSERT INT= O "
               = + ESQUEMA
               = + ".compromisso (com_id, com_criacao, com_data, "
                + "com_titulo, com_confidencial, tco_id, com_agendamento, aud_id, "
               = + "via_id, soe_id)"
               = + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";

        try {

            chave =3D Connecti= onManager.getSequence("comp_seq");
            int i =3D 1;

            stp =3D conn.prepa= reStatement(sql);

            stp.setInt(i++, ch= ave);
            Date agora =3D new= Date();
            stp.setTimestamp(i= ++, new Timestamp(agora.getTime()));

            SimpleDateFormat s= d =3D new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            log.debug("In= serir - Data compromisso: " + sd.format(vo.getData()));
            stp.setTimestamp(i= ++, new Timestamp(vo.getData().getTime()));
            stp.setString(i++,= vo.getTitulo());
            stp.setString(i++,= vo.getConfidencial());
            stp.setInt(i++, vo= .getTipo().getCodigo());
            stp.setString(i++,= vo.getTipoAgendamento());
            if (vo.getAudienci= a() > 0){
               = stp.setInt(i++, vo.getAudiencia());
            } else {
               = stp.setNull(i++, Types.INTEGER);
            }
            if (vo.getViagem()= > 0){
               = stp.setInt(i++, vo.getViagem());
            } else {
               = stp.setNull(i++, Types.INTEGER);
            }
            if (vo.getSolenida= de() > 0){
               = stp.setInt(i++, vo.getSolenidade());
            } else {
               = stp.setNull(i++, Types.INTEGER);
            }
           
            stp.execute();

        } catch (NegocioException ne) {
            throw ne;
        } catch (Exception e) {
            log.debug("sq= l: " + sql);
            throw new NegocioE= xception("error.inserir.compromisso", e);
        }

        return chave;
    }
############################

The vo.getData() return the date which was typed by the user, I logged the date to see if it was right and I got it was, but when I look at the database the date is one hour before.

Log: 2006-01-25 16:05:08,877 -> DEBUG (CompromissoDAO.java:140) - Altera= r - Data compromisso: 12/01/2006 12:00:00
The data which was saved at the database: 2006-01-12 11:00:00

My table script is:

CREATE TABLE compromisso
(
  com_id numeric(6) NOT NULL,
  com_criacao timestamp NOT NULL,
  com_data timestamp NOT NULL,
  com_titulo varchar(200) NOT NULL,
  com_confidencial varchar(400),
  com_agendamento char(1),
  tco_id numeric(6) NOT NULL,
  aud_id numeric(6),
  via_id numeric(6),
  soe_id numeric(6),
  CONSTRAINT compromisso_pk PRIMARY KEY (com_id),
  CONSTRAINT com_tipocompromisso_fk FOREIGN KEY (tco_id) REFERENCES compromisso_tipo (tco_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
  CONSTRAINT compromisso_audiencia_fk FOREIGN KEY (aud_id) REFERENCES registro_audiencia (aud_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
  CONSTRAINT compromisso_solenidade_fk FOREIGN KEY (soe_id) REFERENCES registro_solenidade (soe_id) ON UPDATE RESTRICT ON DELETE RESTRICT,
  CONSTRAINT compromisso_viagem_fk FOREIGN KEY (via_id) REFERENCES registro_viagem (via_id) ON UPDATE RESTRICT ON DELETE RESTRICT
)
WITHOUT OIDS;
ALTER TABLE compromisso OWNER TO uzzi;
GRANT ALL ON TABLE compromisso TO uzzi;


Does any one have an idea what is going in on?

Thanks,

--
Lucas Sanabio
----------------------= -------------------------------------------------------
Sun Certified Pr= ogrammer for the Java 2 Platform
Consultor Java - Marx Tecnologia
Email: lucas@marx.com.br
Cel: (= 61) 8402-8876

------=_Part_56492_17057505.1138214759037--