code: public static String buildSqlSELECT(String tableName, String[][] columns, String[] whereColumns,
              Object[] whereValues) {
          final String SQL_TEMPLATE_WHERE = "SELECT {1} FROM {0} WHERE {2}";
          final String SQL_TEMPLATE = "SELECT {1} FROM {0}";
  
          final List<String> WHERE_CLAUSE = new ArrayList<String>();
          if (whereColumns != null && whereValues != null) {
              if (whereColumns.length != whereValues.length) {
                  throw new IllegalArgumentException(
                          "Number of whereColumns must be equal to number of whereValues.");
              }
              for (int i = 0; i < whereColumns.length; i++) {
                  if (whereValues[i] instanceof ParamExpression) {
                      WHERE_CLAUSE.add("(" + whereColumns[i] + "="
                              + ((ParamExpression) whereValues[i]).getExpression() + ")");
                  } else {
                      WHERE_CLAUSE.add("(" + whereColumns[i] + "=?)");
                  }
              }
          }
  
          final List<String> SELECT_COLUMNS = new ArrayList<String>();
          for (String[] colDef : columns) {
              if (colDef.length > 1) {
                  SELECT_COLUMNS.add(colDef[0] + " AS " + colDef[1]);
              } else {
                  SELECT_COLUMNS.add(colDef[0]);
              }
          }
  
          String SQL;
          if (WHERE_CLAUSE.size() > 0) {
              SQL = MessageFormat.format(SQL_TEMPLATE_WHERE, tableName,
                      StringUtils.join(SELECT_COLUMNS, ", "),
                      StringUtils.join(WHERE_CLAUSE, " AND "));
          } else {
              SQL = MessageFormat.format(SQL_TEMPLATE, tableName,
                      StringUtils.join(SELECT_COLUMNS, ", "));
          }
  
          return SQL;
      }
docs: Builds a SELECT statement (used for {@link PreparedStatement}).
  
  @param tableName
  @param columns
  @param whereColumns
  @param whereValues
  @return