{"record":{"id":"73dd6614be86a1ae","repo":"pentaho/pentaho-kettle","slug":"database-unabletocheckifconnectionpoolexists-exception","errorCode":null,"errorMessage":"Database.UnableToCheckIfConnectionPoolExists.Exception","messagePattern":"Database\\.UnableToCheckIfConnectionPoolExists\\.Exception","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/ConnectionPoolUtil.java","lineNumber":77,"sourceCode":"  public static final String LOG_ABANDONED = \"logAbandoned\";\n  private static Class<?> PKG = Database.class; // for i18n purposes, needed by Translator2!!\n\n  private static ConcurrentMap<String, BasicDataSource> dataSources = new ConcurrentHashMap<String, BasicDataSource>();\n  private static Map<String, Properties> dataSourcesAttributesMap = new HashMap<>();\n\n  // PDI-12947\n  private static final ReentrantLock lock = new ReentrantLock();\n\n  public static final int defaultInitialNrOfConnections = 5;\n  public static final int defaultMaximumNrOfConnections = 10;\n\n  private static boolean isDataSourceRegistered( DatabaseMeta dbMeta, String partitionId )\n    throws KettleDatabaseException {\n    try {\n      String name = getDataSourceName( dbMeta, partitionId );\n      return dataSources.containsKey( name ) && hasOldConfig( dbMeta, partitionId );\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG,\n          \"Database.UnableToCheckIfConnectionPoolExists.Exception\" ), e );\n    }\n  }\n\n  public static DataSource getDataSource( LogChannelInterface log, DatabaseMeta dbMeta, String partitionId ) throws KettleDatabaseException {\n    int initialSize = dbMeta.getInitialPoolSize();\n    int maximumSize = dbMeta.getMaximumPoolSize();\n\n    lock.lock();\n    try {\n      if ( !isDataSourceRegistered( dbMeta, partitionId ) ) {\n        addPoolableDataSource( log, dbMeta, partitionId, initialSize, maximumSize );\n      }\n    } finally {\n      lock.unlock();\n    }\n    return dataSources.get( getDataSourceName( dbMeta, partitionId ) );\n  }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/ConnectionPoolUtil.java#L59-L95","documentation":"ConnectionPoolUtil.isDataSourceRegistered wraps any exception encountered while checking the shared DataSource registry into 'Database.UnableToCheckIfConnectionPoolExists.Exception'. It means the registration lookup (computing the data source name or checking old-config) blew up, so pool status can't be determined.","triggerScenarios":"getDataSource → isDataSourceRegistered throws when getDataSourceName(dbMeta, partitionId) or hasOldConfig(...) throws — e.g. DatabaseMeta fields null/invalid while composing the pool name, or an unexpected error inside hasOldConfig's config comparison.","commonSituations":"Null or incomplete DatabaseMeta passed to getDataSource (missing name/attributes); corrupted partitionId; unexpected RuntimeException from config comparison logic; concurrent modification of the registry.","solutions":["Inspect the chained cause of the KettleDatabaseException to find the real failure","Validate the DatabaseMeta is fully populated (name, connection details) before calling getDataSource","Ensure partitionId is valid/non-null where partitioning is used","Fix the root cause inside getDataSourceName/hasOldConfig if the exception is reproducible with valid input"],"exampleFix":"// before\nDataSource ds = ConnectionPoolUtil.getDataSource( log, possiblyIncompleteDbMeta, partitionId );\n// after\nif ( dbMeta.getName() == null || dbMeta.getHostname() == null ) {\n  throw new KettleException( \"DatabaseMeta incomplete: name and hostname are required for pooling\" );\n}\nDataSource ds = ConnectionPoolUtil.getDataSource( log, dbMeta, partitionId );","handlingStrategy":"try-catch","validationCode":"// Validate DatabaseMeta before touching the pool\nif ( dbMeta == null || dbMeta.getName() == null ) {\n  throw new IllegalArgumentException( \"DatabaseMeta with a non-null name is required for connection pooling\" );\n}","typeGuard":"boolean poolReady( DatabaseMeta dbMeta ) { return dbMeta != null && dbMeta.getName() != null && !dbMeta.getName().trim().isEmpty(); }","tryCatchPattern":"try { ds = ConnectionPoolUtil.getDataSource( log, dbMeta, partitionId ); } catch ( KettleDatabaseException e ) { log.error( \"Pool registration check failed; cause: \" + e.getCause(), e ); throw new IllegalStateException( e ); }","preventionTips":["Always populate DatabaseMeta name/connection attributes before pooling","Keep partitionId null or valid, never a corrupted value","Inspect getCause() to find the true failure inside getDataSourceName/hasOldConfig","Add unit tests covering null/incomplete DatabaseMeta inputs"],"tags":["connection-pool","database","registry"],"backgroundTag":"database-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}