Java Reference
In-Depth Information
public
public static
static String getStatement ( BufferedReader is )
throws
throws IOException {
StringBuilder sb = new
new StringBuilder ();
String line ;
while
while (( line = is . readLine ()) != null
null ) {
iif ( verbosity == Verbosity . DEBUG ) {
System . out . println ( "SQLRunner.getStatement(): LINE " + line );
}
iif ( line == null
null || line . length () == 0 ) {
continue
continue ;
}
line = line . trim ();
iif ( line . startsWith ( "#" ) || line . startsWith ( "--" )) {
continue
continue ;
}
iif ( line . startsWith ( "\\" )) {
iif ( sb . length () != 0 ) {
throw
throw new
new IllegalArgumentException (
"Escape command found inside statement" );
}
}
sb . append ( line );
int
int nb = sb . length ();
// If the buffer currently ends with ';', return it.
iif ( nb > 0 && sb . charAt ( nb - 1 ) == ';' ) {
iif ( nb == 1 ) {
return
return null
null ;
}
sb . setLength ( nb - 1 );
return
return sb . toString ();
}
// Add a space in case the SQL is generated by a tool
// that doesn't remember to add spaces (hopefully this won't
// break tools that output newlines inside quoted strings!).
sb . append ( ' ' );
}
return
return null
null ;
}
public
public void
throws SQLException {
iif ( statement != null
void close () throws
null ) {
statement . close ();
}
iif ( conn != null
null ) {
conn . close ();
Search WWH ::




Custom Search