String ts1Str = null;
    public void testTimestampWithCalendar() throws Exception {        //Connection connection = getConnectionViaDriverManager();                Properties props = new Properties();        props.putAll(getDefaultPropertiesForConnection());        props.setProperty("timestamp_uses_local_timezone", "");                Connection connection = DriverManager.getConnection(getUrl(), props);        try {            PreparedStatement stmt = connection.prepareStatement(                "INSERT INTO test_blob(id, ts_field) VALUES (?, ?)");                        try {                Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+01"));                                Timestamp ts = new Timestamp(calendar.getTime().getTime());                                stmt.setInt(1, 1);                stmt.setTimestamp(2, ts);                                stmt.execute();                                stmt.setInt(1, 2);                stmt.setTimestamp(2, ts, calendar);                                stmt.execute();                stmt.setInt(1, 3);                stmt.setTimestamp(2, ts, Calendar.getInstance(TimeZone.getTimeZone("UTC")));                                stmt.execute();                                                Statement selectStmt = connection.createStatement();                try {                    ResultSet rs = selectStmt.executeQuery(                        "SELECT id, CAST(ts_field AS VARCHAR(30)), ts_field FROM test_blob");                                        Timestamp ts1 = null;                    Timestamp ts2 = null;                    Timestamp ts3 = null;                                        String ts1Str = null;                    String ts2Str = null;                    String ts3Str = null;                                        int maxLength = 23;                                        // workaround for the bug in java.sql.Timestamp in JDK 1.3                     if ("1.3".equals(System.getProperty("java.specification.version")))                        maxLength = 19;                                        while(rs.next()) {                                                switch(rs.getInt(1)) {                            case 1 :                                ts1 = rs.getTimestamp(3);                                ts1Str = rs.getString(2).substring(0, maxLength);                                break;                                                            case 2 :                                ts2 = rs.getTimestamp(3);                                ts2Str = rs.getString(2).substring(0, maxLength);                                break;                                                            case 3 :                                 ts3 = rs.getTimestamp(3);                                ts3Str = rs.getString(2).substring(0, maxLength);                                break;                        }                        /*                        System.out.println("ID " + rs.getInt(1) +                             ", time_str '" + rs.getString(2) +                             "', time ts " + rs.getTimestamp(3) +                             ", time ts_cal " + rs.getTimestamp(3, Calendar.getInstance(TimeZone.getTimeZone("GMT+01"))) +                            ", time ts_zone " + rs.getTimestamp(3, Calendar.getInstance(TimeZone.getTimeZone("UTC"))));                        */                    }                                        assertTrue("Timestamps 1 and 2 should be equal",                         ts1.getTime() == ts2.getTime());                                        assertTrue("Timestamps 1 and 3 should differ for 3600 seconds.",                        Math.abs(ts1.getTime() - ts3.getTime()) == 3600*1000);                                        assertTrue("Server should see the same timestamp",                        ts1.toString().substring(0,  maxLength).equals(ts1Str));                    assertTrue("Server should see the same timestamp",                        ts2.toString().substring(0, maxLength).equals(ts2Str));                    assertTrue("Server should see the same timestamp",                        ts3.toString().substring(0, maxLength).equals(ts3Str));                } finally {                    selectStmt.close();                }                            } finally {                stmt.close();            }                    } finally {            connection.close();        }    }