String command = . . . ; boolean hasResultSet = stat.execute(command); if (hasResultSet) { ResultSet result = stat.getResultSet(); . . . { else { int count = stat.getUpdateCount(); . . . }