1 Reply Latest reply on Jul 6, 2004 2:46 AM by Alexey Loubyansky

    Possible CMP bug?

    bmenarek Newbie


      I am using JBOSS 3.2.3 and MYSQL 4.0.17

      An EJB has a Date attribute. The client uses the java.util.Date class along with the SimpleDateFormat class. The bean maps the attribute to a MYSQL datetime field.

      The parse string used by the client is MM-dd-yyyy. Or stated differently time doe not matter. When one invokes the toString method on a date instance the time comes up all zeroes 00:00:00.

      My problem is that out of approximately 200 records about 80 have a time value of 01:00:00 and one record had a value of 23:00:00 which caused inconsistent behaviour on my clients because they saw it as different days. When I changed the time to 00:00:00 the beahiour stoped. I infer from this that the problem had to do with the time being so close to the EOD.

      I wrote a quick and dirt test that wrote out and retrieved the Java date to the MYSQL datetime and it always worked.

      Any help or insite would be greatly appreciated.

      The following is my test code

      public class DateIssue {
      public static void main(String[] args)
      SimpleDateFormat df = new SimpleDateFormat( Cosignee.dateFormat);
      Date delivery = null;
      delivery = df.parse( "06-30-2004" );
      }catch( Exception e ){}
      // //'YYYY-MM-DD HH:MM:SS'
      SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String deliveryDate = df2.format( delivery );
      System.out.println( deliveryDate );

      Class.forName( "com.mysql.jdbc.Driver" );
      catch( ClassNotFoundException notFound ){
      System.out.println( "ClassNotFoundException");
      String returnValue = null;
      Connection conn = DriverManager.getConnection(

      for( int count = 0; count < 1000000; count++ ){
      Statement statement = conn.createStatement();
      String SQL = "insert into testdate values('" +
      deliveryDate + "')";

      // System.out.println(SQL);
      statement.execute( SQL );

      SQL = "SELECT * FROM `testdate`";
      // System.out.println( SQL );
      ResultSet result = statement.executeQuery( SQL );

      int curPo = 0;
      int nextPo = 0;
      Date retrieved = null;
      if( result.next()){
      retrieved = result.getDate(1);
      // System.out.println( retrieved.toString() );
      if( delivery.compareTo( retrieved ) != 0 ){
      System.out.println("The sucka aint equal!!!");

      SQL = "delete from `testdate` where deliveryDate = '2004-06-30 00:00:00'";

      // System.out.println(SQL);
      statement.execute( SQL );

      }catch( SQLException sqlException ){
      System.out.println( "SQLException:" + sqlException.getMessage());
      System.out.println( "Fini");