Details

    Description

      On updating the mariaDB Connector from 1.1.8 to 1.3.1 a class cast exception is throwing on insert a long value to a BIGINTEGER column in the database.

      In version 1.1.8 it was posstible to create a prepared Statement with the method "setObject(1, valueLong, Types.BIGINT)". Now it throws at this point the exception.

      An executable example (from eclipse IDE) is in the attachment including the two connector jars.

      Attachments

        Activity

          diego dupin Diego Dupin added a comment - - edited

          Corrected in futur correction release 1.3.2

          Additionnal test case added :

           
              @Test
              public void setObjectBitInt() throws SQLException, IOException {
           
                  PreparedStatement preparedStatement = sharedConnection.prepareStatement("INSERT INTO TestBigIntType "
                          + "(t1, t2, t3, t4) VALUES (?, ?, ?, ?)");
           
                  final long valueLong = System.currentTimeMillis();
                  final String maxValue = String.valueOf(Long.MAX_VALUE);
           
                  preparedStatement.setObject(1, valueLong, Types.BIGINT);
                  preparedStatement.setObject(2, maxValue, Types.BIGINT);
                  preparedStatement.setObject(3, valueLong);
                  preparedStatement.setObject(4, maxValue);
                  preparedStatement.executeUpdate();
           
                  Statement statement = sharedConnection.createStatement();
                  ResultSet rs = statement.executeQuery("SELECT * FROM TestBigIntType");
                  validateResultBigIntType(valueLong, maxValue, rs);
           
           
                  PreparedStatement ps = sharedConnection.prepareStatement("SELECT * FROM TestBigIntType Where 1 = ?");
                  ps.setInt(1, 1);
                  rs =  ps.executeQuery();
                  validateResultBigIntType(valueLong, maxValue, rs);
           
              }
           
              private void validateResultBigIntType(long valueLong, String maxValue, ResultSet resultSet) throws SQLException {
                  if (resultSet.next()) {
                      assertEquals(resultSet.getLong(1), valueLong);
                      assertEquals(resultSet.getLong(2), Long.parseLong(maxValue));
                      assertEquals(resultSet.getLong(3), valueLong);
                      assertEquals(resultSet.getLong(4), Long.parseLong(maxValue));
                  } else {
                      fail();
                  }
              }

          diego dupin Diego Dupin added a comment - - edited Corrected in futur correction release 1.3.2 Additionnal test case added :   @Test public void setObjectBitInt() throws SQLException, IOException {   PreparedStatement preparedStatement = sharedConnection.prepareStatement( "INSERT INTO TestBigIntType " + "(t1, t2, t3, t4) VALUES (?, ?, ?, ?)" );   final long valueLong = System.currentTimeMillis(); final String maxValue = String.valueOf(Long.MAX_VALUE);   preparedStatement.setObject( 1 , valueLong, Types.BIGINT); preparedStatement.setObject( 2 , maxValue, Types.BIGINT); preparedStatement.setObject( 3 , valueLong); preparedStatement.setObject( 4 , maxValue); preparedStatement.executeUpdate();   Statement statement = sharedConnection.createStatement(); ResultSet rs = statement.executeQuery( "SELECT * FROM TestBigIntType" ); validateResultBigIntType(valueLong, maxValue, rs);     PreparedStatement ps = sharedConnection.prepareStatement( "SELECT * FROM TestBigIntType Where 1 = ?" ); ps.setInt( 1 , 1 ); rs = ps.executeQuery(); validateResultBigIntType(valueLong, maxValue, rs);   }   private void validateResultBigIntType( long valueLong, String maxValue, ResultSet resultSet) throws SQLException { if (resultSet.next()) { assertEquals(resultSet.getLong( 1 ), valueLong); assertEquals(resultSet.getLong( 2 ), Long.parseLong(maxValue)); assertEquals(resultSet.getLong( 3 ), valueLong); assertEquals(resultSet.getLong( 4 ), Long.parseLong(maxValue)); } else { fail(); } }

          People

            diego dupin Diego Dupin
            fahrenholz sfahren
            Votes:
            1 Vote for this issue
            Watchers:
            4 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.