@ SuppressWarnings ( "unchecked" ) protected boolean executeSQLStmt ( final ISelectionProvider _sqlProvider , final String _complStmt ) throws EFapsException { SQLRunner . LOG . debug ( "SQL-Statement: {}" , _complStmt ) ; boolean ret = false ; List < Object [ ] > rows = new ArrayList <> ( ) ; boolean cached = false ; if ( runnable . has ( StmtFlag . REQCACHED ) ) { final QueryKey querykey = QueryKey . get ( Context . getThreadContext ( ) . getRequestId ( ) , _complStmt ) ; final Cache < QueryKey , Object > cache = QueryCache . getSqlCache ( ) ; if ( cache . containsKey ( querykey ) ) { final Object object = cache . get ( querykey ) ; if ( object instanceof List ) { rows = ( List < Object [ ] > ) object ; } cached = true ; } } if ( ! cached ) { ConnectionResource con = null ; try { con = Context . getThreadContext ( ) . getConnectionResource ( ) ; final Statement stmt = con . createStatement ( ) ; final ResultSet rs = stmt . executeQuery ( _complStmt ) ; final ArrayListHandler handler = new ArrayListHandler ( Context . getDbType ( ) . getRowProcessor ( ) ) ; rows = handler . handle ( rs ) ; rs . close ( ) ; stmt . close ( ) ; } catch ( final SQLException e ) { throw new EFapsException ( SQLRunner . class , "executeOneCompleteStmt" , e ) ; } if ( runnable . has ( StmtFlag . REQCACHED ) ) { final ICacheDefinition cacheDefinition = new ICacheDefinition ( ) { @ Override public long getLifespan ( ) { return 5 ; } @ Override public TimeUnit getLifespanUnit ( ) { return TimeUnit . MINUTES ; } } ; QueryCache . put ( cacheDefinition , QueryKey . get ( Context . getThreadContext ( ) . getRequestId ( ) , _complStmt ) , rows ) ; } } for ( final Object [ ] row : rows ) { for ( final Select select : _sqlProvider . getSelection ( ) . getAllSelects ( ) ) { select . addObject ( row ) ; } ret = true ; } return ret ; }
Execute SQL stmt .