pentaho/pentaho-kettle · error · RuntimeException

e.toString()

Error message

e.toString()

What it means

The outer try in fireToDB covers setup steps such as obtaining the step reference, resolving the DatabaseMeta, opening the Database connection, and setting the query limit. Any exception raised there is rethrown as RuntimeException(e.toString()), flattening the original exception into a bare string.

Solutions

  1. Decode the embedded exception message to identify the connection or setup failure.
  2. Verify host, port, database name, user and password on the named connection.
  3. Confirm the JDBC driver jar is present on the classpath/lib directory.
  4. Test the connection from the Database Connection dialog before scripting against it.

Example fix

// before
fireToDB('MyConn', sql); // connection not opened
// after
// Test/fix the MyConn connection (host, port, credentials, driver), then rerun:
fireToDB('MyConn', sql);
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check connection settings before fireToDB
var ok = _step_.getTransMeta().findDatabase('MyConn') != null;

Try / catch

try { fireToDB('MyConn', sql); } catch (e) { var setupErr = String(e); /* handle connection/setup failure, e.g. retry or alert */ }

Prevention

When it happens

Trigger: Failures before SQL execution: _step_ binding missing, shareVariablesWith or Database construction failed, or the Database connection could not be opened (bad host, port, credentials, driver).

Common situations: Database server unreachable; wrong JDBC driver; invalid credentials; transformation executed in a context where the step binding is unavailable.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

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

          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;
        } else {
          java.util.Date dIn1 = (java.util.Date) ArgList[0];
          java.util.Date dIn2 = (java.util.Date) ArgList[1];

View on GitHub (pinned to f3058517a1)