Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-416

IllegalArgumentException with getTimestamp

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Cannot Reproduce
    • 1.5.7
    • N/A
    • Other
    • None
    • Ubuntu 16.04, Mac OSX

    Description

      We are experiencing an Issue when using the following Setup (on multiple machines):

      • Apache Tomcat-Server (7 or 8)
      • Jersey Web-Application (2.13)
      • Spring-JDBC (4.3.5.RELEASE)
      • MariaDB ConnectorJ 1.5.7
      • MariaDB 10.0.29 or MySQL 5.6.33

      When reading timestamps from a result set (MariaSelectResultSet) via MariaSelectResultSet.getTimestamp, we are receiving the following exception:

      java.lang.IllegalArgumentException: nanos > 999999999 or < 0
      	at java.sql.Timestamp.setNanos(Timestamp.java:389)
      	at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.binaryTimestamp(MariaSelectResultSet.java:3533)
      	at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getTimestamp(MariaSelectResultSet.java:1676)
      	at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getTimestamp(MariaSelectResultSet.java:1606)
      	at org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet.getTimestamp(MariaSelectResultSet.java:1579)
      

      However, the exception seems to ONLY appear if we include a WHERE clause in the SQL statement. Reading the (very) same timestamps without WHERE leads to no errors. Also, I cannot see any difference between the timestamps when printing the values with getObject or getString instead of getTimestamp. Receiving the timestamps with getString and parsing them to a java.sql.Timestamps after works without issues. The timestamps are stored with the type timestamp(2).

      The same code works with an MySQL driver without any issues (the initial reason for us to use the MariaDB driver was that we wanted to support milliseconds, which could not be inserted into MariaDB with the MySQL driver).

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            rob-k Robin K
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.