Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » MySQL issue ArithmeticException: / by zero
MySQL issue ArithmeticException: / by zero [message #1097400] Thu, 29 August 2013 17:05 Go to next message
Chris Snow is currently offline Chris SnowFriend
Messages: 50
Registered: December 2011
Member
When a table's execLoadTableData is run, I get the following error:

Caused by: java.lang.ArithmeticException: / by zero
	at org.eclipse.scout.rt.server.services.common.jdbc.internal.exec.StatementProcessor.processResultRows(StatementProcessor.java:230)
	at org.eclipse.scout.rt.server.services.common.jdbc.internal.exec.StatementProcessor.processSelect(StatementProcessor.java:265)
	... 70 more


A bit of debugging reveals the root cause in StatementProcessor:

 protected List<Object[]> processResultRows(ResultSet rs, int maxRowCount) throws SQLException, ProcessingException {
    boolean isDynamicPrefetch = false;
    int rowCount = 0;
    int initialFetchSize = 0;
    int dynamicFetchSize = 0;
    if (m_callerService.getSqlStyle() != null && m_callerService.getSqlStyle() instanceof OracleSqlStyle) {
      // init prefetch params
      isDynamicPrefetch = true;
      initialFetchSize = rs.getFetchSize();
      dynamicFetchSize = initialFetchSize;
    }
    ArrayList<Object[]> rows = new ArrayList<Object[]>();
    while (rs.next()) {
      if (isDynamicPrefetch && ++rowCount % dynamicFetchSize == 0 && dynamicFetchSize < getMaxFetchSize(rs)) {
        dynamicFetchSize = Math.min(Math.max(initialFetchSize, rowCount / 2), getMaxFetchSize(rs));
        rs.setFetchSize(dynamicFetchSize);
      }
      Object[] row = processResultRow(rs);
      rows.add(row);
      if (maxRowCount > 0 && rows.size() >= maxRowCount) {
        break;
      }
    }
    return rows;
  }


The problem seems to be that m_callerService.getSqlStyle() is returning org.eclipse.scout.rt.server.services.common.jdbc.style.OracleSqlStyle and
then initialFetchSize = rs.getFetchSize() is returning 0 which is causing a divide by zero on ++rowCount % dynamicFetchSize

Scout: 3.9
MySQL: 5.6
MySQL Connector: 5.1.17

[Updated on: Thu, 29 August 2013 17:22]

Report message to a moderator

Re: MySQL issue ArithmeticException: / by zero [message #1097412 is a reply to message #1097400] Thu, 29 August 2013 17:27 Go to previous messageGo to next message
Chris Snow is currently offline Chris SnowFriend
Messages: 50
Registered: December 2011
Member
I found the problem, my SqlService extended AbstractSqlService and not AbstractMySqlSqlService
Re: MySQL issue ArithmeticException: / by zero [message #1591461 is a reply to message #1097412] Thu, 29 January 2015 14:49 Go to previous messageGo to next message
Santo Mota is currently offline Santo MotaFriend
Messages: 63
Registered: July 2013
Member
Thank you very much, your comment help a lot.
Re: MySQL issue ArithmeticException: / by zero [message #1778156 is a reply to message #1097400] Mon, 11 December 2017 11:21 Go to previous messageGo to next message
Andrea Tempia Scopello is currently offline Andrea Tempia ScopelloFriend
Messages: 2
Registered: December 2017
Junior Member
Thank you!!! i've lost a lot of time before found your solution!
I've the same problem with DB2. The right class in this case is "AbstractDB2SqlService".
Re: MySQL issue ArithmeticException: / by zero [message #1778157 is a reply to message #1097400] Mon, 11 December 2017 11:22 Go to previous message
Andrea Tempia Scopello is currently offline Andrea Tempia ScopelloFriend
Messages: 2
Registered: December 2017
Junior Member
Thank you! i've lost a lot of time before found your solution!

I've the same problem with DB2.
The right extension for my problem is "AbstractDB2SqlService".
Previous Topic:ODATA With Eclipse Scout
Next Topic:Custom Widget: how to filter keys ?
Goto Forum:
  


Current Time: Fri Apr 19 10:26:51 GMT 2024

Powered by FUDForum. Page generated in 0.02622 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top