pentaho/pentaho-kettle · error · RuntimeException

er.toString()

Error message

er.toString()

What it means

Inside fireToDB, after the Database object is opened, the inner try block that executes the SQL and converts the result list into Object[][] wraps failures in a RuntimeException carrying er.toString() — the plain string of the original exception, losing the stack trace.

Solutions

  1. Read the embedded message for the real database error and fix the SQL or connection accordingly.
  2. Validate the SQL manually against the target database before running the transformation.
  3. Wrap the fireToDB call in script try/catch to log details.
  4. Replace fireToDB with a dedicated Execute SQL / Table Output step for complex work to get better error reporting.

Example fix

// before
fireToDB('MyConn', 'DELETE FROM logs WERE id < 100');
// after
fireToDB('MyConn', 'DELETE FROM logs WHERE id < 100');
Defensive patterns

Strategy: try-catch

Validate before calling

// test SQL first: fireToDB('MyConn', 'SELECT 1');

Try / catch

try { fireToDB('MyConn', sql); } catch (e) { var dbErr = String(e); /* inspect underlying SQL error text */ }

Prevention

When it happens

Trigger: The SQL execution inside the inner try fails: syntax error in the passed SQL, wrong table/column names, connection failure during execution, or result conversion problems.

Common situations: Invalid SQL statements passed from script; querying a table that does not exist on the target connection; database down or credentials changed between lookup and execution.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/04e4a04406804999. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/ScriptAddedFunctions.java:523

          ResultSet rs = db.openQuery( strSQL );
          ResultSetMetaData resultSetMetaData = rs.getMetaData();
          int columnCount = resultSetMetaData.getColumnCount();
          if ( rs != null ) {
            List<Object[]> list = new ArrayList<Object[]>();
            while ( rs.next() ) {
              Object[] objRow = new Object[columnCount];
              for ( int i = 0; i < columnCount; i++ ) {
                objRow[i] = rs.getObject( i + 1 );
              }
              list.add( objRow );
            }
            Object[][] resultArr = new Object[list.size()][];
            list.toArray( resultArr );
            db.close();
            return resultArr;
          }
        } catch ( Exception er ) {
          throw new RuntimeException( er.toString() );
        }
      } catch ( Exception e ) {
        throw new RuntimeException( e.toString() );
      }
    } else {
      throw new RuntimeException( "The function call fireToDB requires 2 arguments." );
    }
    return oRC;
  }

  public static Object dateDiff( ScriptEngine actualContext, Bindings actualObject, Object[] ArgList,
    Object FunctionContext ) {
    if ( ArgList.length == 3 ) {
      try {
        if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
          return new Double( Double.NaN );
        } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
          return undefinedValue;

View on GitHub (pinned to f3058517a1)