protected boolean isStoredProcedure ( String sql ) { /* Stored procedures start with {?= call <procedure-name>[<arg1>,<arg2>, ...]} or {call <procedure-name>[<arg1>,<arg2>, ...]} but also statements with white space like { ?= call <procedure-name>[<arg1>,<arg2>, ...]} are possible. */ int k = 0 , i = 0 ; char c ; while ( k < 3 && i < sql . length ( ) ) { c = sql . charAt ( i ) ; if ( c != ' ' ) { switch ( k ) { case 0 : if ( c != ' ' ) return false ; break ; case 1 : if ( c != ' ' && c != ' ' ) return false ; break ; case 2 : if ( c != ' ' && c != ' ' ) return false ; break ; } k ++ ; } i ++ ; } return true ; }
Check if the specified sql - string is a stored procedure or not .