DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Threaded View

  1. #1
    Fabio Luis De Paoli Guest

    Wierd JDBC behaviour

    I am getting wierd results reading a datetime year to fraction(3) from an
    Informix IDS 7.30U C6 database. My code is compiled by VisualCafe 3
    (JDK 1.1) and my tests were done in two machines:

    - An HP-UX 10.20 server with JRE 1.1 and the Informix JDBC 1.5 JAR,
    with TZ set to BRA3VER (GMT -2 at this moment)
    - My Windows98 PC with VisualCafe's JRE 1.1 and the Informix JDBC
    1.5 JAR set to Rio TimeZone with DST (GMT -2 at this moment)

    The results, obtained executing the exact same .class file (source listed
    further ahead) are:

    Running on the HP-UX server:
    Debug get, AWB: 2405604751, db TS: 2000-12-12 13:58:41.000 GMT,
    long : 976629521000

    Running on my PC:
    Debug get, AWB: 2405604751, db TS: 2000-12-12 16:58:41.000 GMT,
    long : 976640321000

    In dbaccess this is what I get with statment select loguser, logdate from
    shipser where awb = "2405604751" :
    loguser logdate
    pegadm 2000-12-12 11:58:41.180

    The code being executed is listed below:

    /////////////// START OF CODE //////////////////

    anSQL = new String("select logdate "
    + "from shipser "
    + "where awb = ?");
    aStmt = aConnex.prepareStatement(anSQL);
    aStmt.setString(1, awbNumber);
    aResult = aStmt.executeQuery();
    aResult.next();

    java.sql.Timestamp dbTimeStamp = aResult.getTimestamp("logdate");

    SimpleDateFormat formatter =
    (SimpleDateFormat) Sage.getDateFormatter().clone();
    // Instruction above equal to
    // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z", Sage.STD_LOCALE);
    // followed by a clone, where STD_LOCALE = Locale.US;

    formatter.setTimeZone(new SimpleTimeZone(0, "GMT"));
    formatter.applyPattern("yyyy-MM-dd HH:mm:ss.SSS z");

    System.out.println("Debug AWB: " + awbNumber
    + ", db TS: " + formatter.format(dbTimeStamp)
    + ", long : " + dbTimeStamp.getTime());

    /////////////// END OF CODE //////////////////

    It seems that the JDBC driver is applying a GMT offset when it reads the
    datetime... and a different offset depending on which machine the code is
    executing. This does not make sense to me - the driver should not touch
    the Date value. Am I missing something?

    Thanks

    Fabio





    Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links