Error calling stored procedure with DECIMAL parameter (CONJ-103)

[CONJ-165] Updates to DECIMAL field through Java Connector return "Method Not Yet Implemented" in LibreOffice Base Created: 2015-07-07  Updated: 2019-08-02  Resolved: 2017-03-30

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.1.7, 1.1.8, 1.1.9
Fix Version/s: N/A

Type: Sub-Task Priority: Major
Reporter: Doug Assignee: Georg Richter
Resolution: Incomplete Votes: 0
Labels: None
Environment:

Windows 7 connecting MariaDB 10.0.13 and 10.0.20 to LibreOffice Base 4.4.7. Problem exists in Java connectors 1.1.7, 1.1.8, and 1.1.9.


Issue Links:
Duplicate
duplicates CONJ-322 ResultSet.update* methods aren't impl... Closed
Relates
relates to CONJ-103 Error calling stored procedure with D... Closed

 Description   

I am encountering a bug that appears related and blocks the use of DECIMAL fields via LibreOffice Base and the Java connector. The DECIMAL field cannot be updated and instead returns the message in LO Base application: "Error updating the current record / Method not yet implemented." There is no additional detail. The update succeeds only when the underling field is changed to DOUBLE. EDIT: backtested, this is not a regression, problem also existed in 1.1.7. I did not previously encounter problem because I was using a different connector (Native LO)



 Comments   
Comment by Diego Dupin [ 2016-01-05 ]

This part has been rewritten to permit using preparedStatement.

This seems to be now ok. Can you confirm ?
Tested with :

    @BeforeClass()
    public static void initClass() throws SQLException {
        createTable("signedDecimalTest", "id DECIMAL(65,20)");
    }
 
 
    @Test
    public void signedDecimalTest() throws SQLException {
        try (PreparedStatement pstmt = sharedConnection.prepareStatement("insert into signedDecimalTest values (?)")) {
            pstmt.setBigDecimal(1, new BigDecimal("123456789012345678901234567890.12345678901234567890"));
            pstmt.addBatch();
            pstmt.setObject(1, new BigDecimal("123456789012345678901234567890.12345678901234567890"), Types.DECIMAL, 0);
            pstmt.addBatch();
            pstmt.setObject(1, new BigDecimal("9223372036854775806"), Types.DECIMAL);
            pstmt.addBatch();
            pstmt.setString(1, "1.1");
            pstmt.addBatch();
            pstmt.setInt(1, 1);
            pstmt.addBatch();
            pstmt.setNull(1, Types.DECIMAL);
            pstmt.addBatch();
            pstmt.setInt(1, -1);
            pstmt.addBatch();
            pstmt.executeBatch();
        }
 
        try (ResultSet rs = DatatypeTest.getResultSet("select * from signedDecimalTest", false)) {
            signedDecimalTestResult(rs);
        }
 
        try (ResultSet rs = DatatypeTest.getResultSet("select * from signedDecimalTest", true)) {
            signedDecimalTestResult(rs);
        }
    }
 
    private void signedDecimalTestResult(ResultSet rs) throws SQLException {
        if (rs.next()) {
            byteMustFail(rs);
            shortMustFail(rs);
            intMustFail(rs);
            longMustFail(rs);
            assertEquals(123456789012345678901234567890.12345678901234567890F, rs.getFloat(1), 1000000000000000000000000D);
            assertEquals(123456789012345678901234567890.12345678901234567890F, rs.getFloat(1), 1000000000000000000000000D);
            assertEquals(123456789012345678901234567890.12345678901234567890D, rs.getDouble(1), 1000000000000000000000000D);
            assertEquals(new BigDecimal("123456789012345678901234567890.12345678901234567890"), rs.getBigDecimal(1));
            assertEquals("123456789012345678901234567890.12345678901234567890", rs.getString(1));
            if (rs.next()) {
                byteMustFail(rs);
                shortMustFail(rs);
                intMustFail(rs);
                longMustFail(rs);
                assertEquals(123456789012345678901234567890.12345678901234567890F, rs.getFloat(1), 1000000000000000000000000D);
                assertEquals(123456789012345678901234567890.12345678901234567890F, rs.getFloat(1), 1000000000000000000000000D);
                assertEquals(123456789012345678901234567890.12345678901234567890D, rs.getDouble(1), 1000000000000000000000000D);
                assertEquals(new BigDecimal("123456789012345678901234567890.12345678901234567890"), rs.getBigDecimal(1));
                assertEquals("123456789012345678901234567890.12345678901234567890", rs.getString(1));
                if (rs.next()) {
                    byteMustFail(rs);
                    shortMustFail(rs);
                    intMustFail(rs);
                    assertEquals(9223372036854775806L, rs.getLong(1));
                    assertEquals(9223372036854775806F, rs.getFloat(1), .000001);
                    assertEquals(9223372036854775806D, rs.getDouble(1), .000001);
                    assertEquals(new BigDecimal("9223372036854775806.00000000000000000000"), rs.getBigDecimal(1));
                    assertEquals("9223372036854775806.00000000000000000000", rs.getString(1));
                    if (rs.next()) {
                        byteMustFail(rs);
                        shortMustFail(rs);
                        intMustFail(rs);
                        longMustFail(rs);
                        assertEquals(1.1F, rs.getFloat(1), .000001);
                        assertEquals(1.1D, rs.getDouble(1), .000001);
                        assertEquals("1.10000000000000000000", rs.getString(1));
                        assertEquals(new BigDecimal("1.10000000000000000000"), rs.getBigDecimal(1));
                        if (rs.next()) {
                            oneNullNegativeTest(rs, true, false);
                        } else {
                            fail("must have result !");
                        }
                    } else {
                        fail("must have result !");
                    }
                } else {
                    fail("must have result !");
                }
            } else {
                fail("must have result !");
            }
        } else {
            fail("must have result !");
        }
    }
 
 
    private void byteMustFail(ResultSet rs) {
        try {
            rs.getByte(1);
            fail("getByte must have thrown error !");
        } catch (SQLException e) {
            assertEquals("22003", e.getSQLState());
        }
    }
 
    private void shortMustFail(ResultSet rs) {
        try {
            rs.getShort(1);
            fail("getShort must have thrown error !");
        } catch (SQLException e) {
            assertEquals("22003", e.getSQLState());
        }
    }
 
    private void intMustFail(ResultSet rs) {
        try {
            rs.getInt(1);
            fail("getInt must have thrown error !");
        } catch (SQLException e) {
            assertEquals("22003", e.getSQLState());
        }
    }
 
    private void longMustFail(ResultSet rs) {
        try {
            rs.getLong(1);
            fail("getLong must have thrown error !");
        } catch (SQLException e) {
            assertEquals("22003", e.getSQLState());
        }
    }
 
    private void oneNullNegativeTest(ResultSet rs, boolean decimal, boolean floatingPoint) throws SQLException {
        try {
            if (!decimal && !floatingPoint) {
                assertTrue(rs.getBoolean(1));
            }
            assertEquals(1, rs.getByte(1));
            assertEquals(1, rs.getShort(1));
            assertEquals(1, rs.getInt(1));
            assertEquals(1L, rs.getLong(1));
            assertEquals(1D, rs.getDouble(1), .000001);
            assertEquals(1F, rs.getFloat(1), .000001);
            if (decimal) {
                if (floatingPoint) {
                    BigDecimal bd = rs.getBigDecimal(1);
                    if (!bd.equals(new BigDecimal("1")) && !bd.equals(new BigDecimal("1.0")) ) {
                        fail("getBigDecimal error : is " + bd.toString());
                    }
                    assertEquals("1.0", rs.getString(1));
 
                } else {
                    assertEquals(new BigDecimal("1.00000000000000000000"), rs.getBigDecimal(1));
                    assertEquals("1.00000000000000000000", rs.getString(1));
 
                }
            } else {
                assertEquals(new BigDecimal("1"), rs.getBigDecimal(1));
                assertEquals("1", rs.getString(1));
            }
        } catch (SQLException e) {
            e.printStackTrace();
            fail("must not have thrown error");
        }
 
        if (rs.next()) {
            nullNegativeTest(rs, decimal);
        } else {
            fail("must have result !");
        }
    }
 
    private void nullNegativeTest(ResultSet rs, boolean decimal) throws SQLException {
        try {
            assertFalse(rs.getBoolean(1));
            assertEquals(0, rs.getByte(1));
            assertTrue(rs.wasNull());
            assertEquals(0, rs.getShort(1));
            assertEquals(0, rs.getInt(1));
            assertEquals(0, rs.getLong(1));
            assertEquals(0, rs.getDouble(1), .00001);
            assertEquals(0, rs.getFloat(1), .00001);
            assertNull(rs.getBigDecimal(1));
            assertNull(rs.getString(1));
 
        } catch (SQLException e) {
            e.printStackTrace();
            fail("must not have thrown error");
        }
 
        if (rs.next()) {
            try {
                assertFalse(rs.getBoolean(1));
                assertFalse(rs.wasNull());
                assertEquals(-1, rs.getByte(1));
                assertEquals(-1, rs.getShort(1));
                assertEquals(-1, rs.getInt(1));
                assertEquals(-1, rs.getLong(1));
                assertEquals(-1, rs.getDouble(1), .00001);
                assertEquals(-1, rs.getFloat(1), .00001);
                if (decimal) {
                    assertTrue(new BigDecimal("-1.00000000000000000000").equals(rs.getBigDecimal(1)));
                    assertEquals("-1.00000000000000000000", rs.getString(1));
                } else {
                    assertTrue(new BigDecimal("-1").equals(rs.getBigDecimal(1)));
                    assertEquals("-1", rs.getString(1));
                }
 
            } catch (SQLException e) {
                e.printStackTrace();
                fail("must not have thrown error");
            }
        } else {
            fail("must have result !");
        }
    }

Comment by Diego Dupin [ 2017-03-30 ]

closing since no answer since a long time

Generated at Thu Feb 08 03:13:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.