[CONJ-810] ResultSet.getDate() return value inconsistent between MySQL and MariaDB connectors Created: 2020-07-22 Updated: 2020-09-24 Resolved: 2020-09-23 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | JDBC compatibility |
| Affects Version/s: | 2.6.1 |
| Fix Version/s: | 2.7.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Bibhas Sarkar | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The getDate() method of the ResultSet returns java.sql.Date however the underlying GregorianDate has the time component. This results in failure of date comparison if assumed that the date always has time set as 00 hours. A simple test between MySQL and MariaDB yields different results /** Code Example **/ //MySQL Driver } } //MariaDB Driver { try(Connection con = new org.mariadb.jdbc.Driver().connect("jdbc:mariadb://localhost:3308/safenet?useUnicode=true&characterEncoding=UTF-8&jdbcCompliantTruncation=false&zeroDateTimeBehavior=convertToNull", credentials)) { try(Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select now()")) { if (rs.next()) { System.out.printf("MariaDB Date Returned: %s\n", sdf.format(rs.getDate(1))); } } } catch (SQLException e) { e.printStackTrace(); } } /** OUTPUT **/ MySQL Date Returned: 2020-Jul-22 00:00:00 =================================================== |
| Comments |
| Comment by Diego Dupin [ 2020-09-23 ] |
|
This concerns the normalization of resultset getDate/getTime of timestamp field. as indicated in javadoc (Time and Date)
Same for java.sql.Time:
example: getTime() on value '2015-03-29T01:45:00.012' return a java.sql.Time with value '01:45:00', submethod getTime return time in millisecond that did correspond to '2015-03-29T01:45:00.012'. Now correspond to '1970-01-01T01:45:00.012' |