pentaho/pentaho-kettle · error · KettleDatabaseException

Unable to check if table [" + tablename + "] exists on…

Error message

Unable to check if table [" + tablename + "] exists on connection [" + databaseMeta.getName() + "]

What it means

Thrown by Database.tableExists(tablename) when the check itself fails with a generic Exception — i.e. the library could not determine whether the table exists. Note that a KettleDatabaseException from the internal probe (SELECT ... FROM table) is interpreted as 'table does not exist' and returns false instead.

Solutions

  1. Verify the database connection is open before calling tableExists()
  2. Inspect the cause for the underlying failure (connection state, permissions)
  3. Use checkTableExists(...) (metadata-based variant) which uses DatabaseMetaData.getTables instead of a probe SELECT
  4. Catch KettleDatabaseException around tableExists and treat as connectivity failure, not 'table missing'

Example fix

// before
boolean exists = database.tableExists("MY_TABLE"); // connection closed
// after
database.connect();
boolean exists = database.tableExists("MY_TABLE");
Defensive patterns

Strategy: try-catch

Validate before calling

if (!database.isOpened()) throw new IllegalStateException("Connect before tableExists check");

Try / catch

boolean exists;
try {
  exists = database.tableExists(tablename);
} catch (KettleDatabaseException e) {
  // distinguish 'check failed' from 'table missing'
  logError("Table existence check failed for " + tablename, e);
  throw e;
}

Prevention

When it happens

Trigger: Database.tableExists(sql-tablename) when getDatabaseMetaData() is null, the connection is closed, or any non-probe exception occurs while running the internal 'SELECT 1 FROM tablename' / catalog query.

Common situations: Calling tableExists before connecting; case-sensitivity or schema-qualified names mishandled; database down or credentials expired so even the probe fails with a non-SQL exception.

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/c7cdf5a09aa348bb. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:2178

   * @return true if the table exists, false if it doesn't.
   * @deprecated Deprecated in favor of {@link #checkTableExists(String, String)}
   */
  @Deprecated
  public boolean checkTableExists( String tablename ) throws KettleDatabaseException {
    try {
      if ( log.isDebug() ) {
        log.logDebug( "Checking if table [" + tablename + "] exists!" );
      }
      // Just try to read from the table.
      String sql = databaseMeta.getSQLTableExists( tablename );
      try {
        getOneRow( sql );
        return true;
      } catch ( KettleDatabaseException e ) {
        return false;
      }
    } catch ( Exception e ) {
      throw new KettleDatabaseException(
        "Unable to check if table [" + tablename + "] exists on connection [" + databaseMeta.getName() + "]", e );
    }
  }

  /**
   * See if the table specified exists.
   *
   * <p>This is a smarter implementation of {@link #checkTableExists(String)} where
   * metadata is used first and we only use statements when absolutely necessary.
   *
   * <p>Contrary to previous versions of similar duplicated methods, this implementation
   * does not require quoted identifiers.
   *
   * @param tablename The unquoted name of the table to check.<br> This is NOT the properly quoted name of the table or
   *                  the complete schema-table name combination.
   * @param schema    The unquoted name of the schema.
   * @return true if the table exists, false if it doesn't.
   */

View on GitHub (pinned to f3058517a1)