{"record":{"id":"0b5d58bb505ca4d5","repo":"pentaho/pentaho-kettle","slug":"couldn-t-get-a-result-because-of-an-error","errorCode":null,"errorMessage":"Couldn't get a result because of an error :","messagePattern":"Couldn't get a result because of an error :","errorType":"exception","errorClass":"InvocationTargetException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/core/database/dialog/GetTableSizeProgressDialog.java","lineNumber":77,"sourceCode":"  }\n\n  public Long open() {\n    IRunnableWithProgress op = new IRunnableWithProgress() {\n      public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {\n        db = new Database( Spoon.loggingObject, dbMeta );\n        try {\n          db.connect();\n\n          String sql = dbMeta.getDatabaseInterface().getSelectCountStatement( tableName );\n          RowMetaAndData row = db.getOneRow( sql );\n          size = row.getRowMeta().getInteger( row.getData(), 0 );\n\n          if ( monitor.isCanceled() ) {\n            throw new InvocationTargetException( new Exception( \"This operation was cancelled!\" ) );\n          }\n\n        } catch ( KettleException e ) {\n          throw new InvocationTargetException( e, \"Couldn't get a result because of an error :\" + e.toString() );\n        } finally {\n          db.close();\n        }\n      }\n    };\n\n    try {\n      final ProgressMonitorDialog pmd = new ProgressMonitorDialog( shell );\n      // Run something in the background to cancel active database queries, forecably if needed!\n      Runnable run = new Runnable() {\n        public void run() {\n          IProgressMonitor monitor = pmd.getProgressMonitor();\n          while ( pmd.getShell() == null || ( !pmd.getShell().isDisposed() && !monitor.isCanceled() ) ) {\n            try {\n              Thread.sleep( 100 );\n            } catch ( InterruptedException e ) {\n              // Ignore\n            }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/core/database/dialog/GetTableSizeProgressDialog.java#L59-L95","documentation":"In GetTableSizeProgressDialog.run, if the SELECT COUNT(*) query (via db.getOneRow) throws a KettleException, it is rethrown as an InvocationTargetException with message 'Couldn't get a result because of an error : ' plus the exception details.","triggerScenarios":"Opening the table-size dialog when the count query fails: connection loss, table doesn't exist, permission denied, or driver-level SQL error.","commonSituations":"Checking table size in Spoon after the table was dropped; connected user lacks SELECT on the table; database unavailable or session timed out.","solutions":["Inspect the InvocationTargetException cause for the underlying SQL error and address it (table name, permissions).","Re-test the connection and retry the size calculation.","Verify the table exists in the current schema using db.checkTableExists(tableName) before computing size.","If COUNT(*) times out on huge tables, use approximate statistics from the database catalog instead."],"exampleFix":"// before\nlong size = new GetTableSizeProgressDialog( shell, dbMeta, tableName ).openSize();\n// after\nif ( db.checkTableExists( tableName ) ) {\n  long size = new GetTableSizeProgressDialog( shell, dbMeta, tableName ).openSize();\n}","handlingStrategy":"try-catch","validationCode":"// verify table exists before computing size\nDatabase db = new Database( loggingObject, dbMeta );\ndb.connect();\nboolean exists = db.checkTableExists( tableName );\ndb.disconnect();","typeGuard":null,"tryCatchPattern":"try {\n  size = new GetTableSizeProgressDialog( shell, dbMeta, tableName ).openSize();\n} catch ( InvocationTargetException e ) {\n  logError( \"Couldn't get table size: \" + e.getCause(), e.getCause() );\n}","preventionTips":["Confirm the table exists and the user can SELECT from it.","Re-test the connection if it may have dropped.","Use estimated statistics for huge tables to avoid slow COUNT(*)."],"tags":["jdbc","sql","database","table-size"],"backgroundTag":"sql-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"}