7 Replies Latest reply on Aug 25, 2003 11:32 AM by wellington.pinheiro

    Strange Problems with Timestamp

    wellington.pinheiro

      Hello, we have an application that works with CMP and Oracle 9i.

      We have a table defined as:

      Table: USER

      USER_NAME VARCHAR2(10)
      PASSWORD RAW(40)
      LAST_CHANGE DATE

      The Entity Bean User is something like that (consider its respective set's):

      public String getUserName();
      public byte[] getPassword();
      public java.sql.Date getLastChange();

      Everything was working fine but we had to change the method getLastChange to work with java.sql.Timestamp (we also need the time in this field) and after this change, when we save the field PASSWORD the data is saved with the 3 last bytes changed!!!!

      For example, if we do:

      user.setLastChange(new bytew[] {-126, 13, 78, -23, -8} );

      the sequence is saved as:

      25, 123, -5, -23, -8 ...something like that!! It's not exactly what it saves....it's just an example!!!

      Does anybody know what's happening here??
      Thanks.

        • 1. Re: Strange Problems with Timestamp
          scoy

          What JDBC/SQL mappings are you using?

          Steve Coy

          • 2. Re: Strange Problems with Timestamp
            wellington.pinheiro

            The datasource-mapping is set to Oracle8.

            For the field we defined as Timestamp we use the default values for the field we use as Password (that is a byte[]) we force the values on jbosscmp-jdbc:

            <jdbc-type>LONGVARBINARY</jdbc-type>
            <sql-type>LONG RAW</sql-type>

            We are using jboss 3.0.3

            • 3. Re: Strange Problems with Timestamp
              scoy

              You are using a very old version of JBoss 3.0.
              In fact, 3.0.4 had significant fixes to the handling of binary data.

              Also, there are now Oracle 9i datasource mappings with proper support for the TimeStamp datatype (which does not exist in Oracle 8).

              Using JBoss 3.0.4 or later, VABINARY/RAW should work fine for your password field.

              Steve Coy

              • 4. Re: Strange Problems with Timestamp
                wellington.pinheiro

                Hi, now I'm using JBoss 3.2.2RC2 and I changed the mapping for Oracle9i.

                If I don't change the type of the column on the database from DATE to TIMESTAMP the problem remains...if I change it works with no problem.

                I tried to force the configuration on the jbosscmp-jdbc to:

                <cmp-field>
                <field-name>dtUltAlterSenha</field-name>
                <column-name>DT_ULT_ALTER_SENHA</column-name>
                <jdbc-type>DATE</jdbc-type>
                <sql-type>DATE</sql-type>
                </cmp-field>

                but jboss throws an exception when it tries to persist the data!!

                I still don't know what's happening here!! But it's really strange!

                • 5. Re: Strange Problems with Timestamp
                  scoy

                  What's the exception?

                  Please show the full stack trace.

                  Is it possible that you created the table with an SQL type of TIMESTAMP initially?

                  Steve Coy

                  • 6. Re: Strange Problems with Timestamp
                    wellington.pinheiro

                    We don't have any field as TIMESTAMP. We always used DATE.

                    I tried to make a change, I redefined the field as VARCHAR2 and in my Entity bean I put a method that converts the byte array to a two digits hexadecimal.

                    It's strange but the problem is still there! I think that it can be a situation where my entity bean (or my session bean maybe) throws some kind of exception that I catch in any part of the code but doesn't show the stack trace !

                    I will provide you the stack trace asap!!

                    Thanks for your help!!

                    • 7. Re: Strange Problems with Timestamp
                      wellington.pinheiro

                      I attached the piece of log messages of my server.log where you can find the stack trace.