diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java index 719f99c5de..e83cb6f18d 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQuery.java @@ -775,11 +775,6 @@ public int hashCode() { * .setUseQueryCache(true) * .build(); * Connection connection = bigquery.createConnection(connectionSettings); - * try { - * connection.executeSelect("SELECT 1"); - * } catch (BigQuerySQLException ex) { - * // handle exception - * } * } * * diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Connection.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Connection.java index 069b2df745..be6b62032e 100644 --- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Connection.java +++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/Connection.java @@ -40,17 +40,39 @@ public interface Connection { BigQueryDryRunResult dryRun(String sql) throws BigQuerySQLException; /** - * Execute a SQL statement that returns a single BigQueryResultSet + * Execute a SQL statement that returns a single ResultSet + * + *
Example of running a query. + * + *
+ * { + * @code + * // ConnectionSettings connectionSettings = + * // ConnectionSettings.newBuilder() + * // .setRequestTimeout(10L) + * // .setMaxResults(100L) + * // .setUseQueryCache(true) + * // .build(); + * // Connection connection = bigquery.createConnection(connectionSettings); + * String selectQuery = "SELECT corpus FROM `bigquery-public-data.samples.shakespeare` GROUP BY corpus;"; + * try (ResultSet rs = connection.executeSelect(selectQuery)) { + * while (rs.next()) { + * System.out.printf("%s,", rs.getString("corpus")); + * } + * } catch (BigQuerySQLException ex) { + * // handle exception + * } + * } + ** * @param sql a static SQL SELECT statement - * @param options JobOptions in case a query job is created for this query - * @return a BigQueryResultSet that contains the data produced by the query + * @return a ResultSet that contains the data produced by the query * @exception BigQuerySQLException if a database access error occurs */ ResultSet executeSelect(String sql) throws BigQuerySQLException; /** - * Execute a SQL statement with query parameters that returns a single BigQueryResultSet + * Execute a SQL statement with query parameters that returns a single ResultSet * * @param sql typically a static SQL SELECT statement * @param parameters named or positional parameters. The set of query parameters must either be @@ -61,8 +83,7 @@ public interface Connection { * contain lowercase letters, numeric characters, underscores and dashes. International * characters are allowed. Label values are optional. Label keys must start with a letter and * each label in the list must have a different key. - * @param options JobOptions in case a query job is created for this query - * @return a BigQueryResultSet that contains the data produced by the query + * @return a ResultSet that contains the data produced by the query * @exception BigQuerySQLException if a database access error occurs */ ResultSet executeSelect(String sql, List