IO exception when inserting data into a table on a large query

I am trying to insert data into a table by big request. I followed a few docs and my last code looks like

HttpTransport TRANSPORT = new NetHttpTransport(); JsonFactory JSON_FACTORY = new JacksonFactory(); List<String> SCOPES = Arrays .asList(BigqueryScopes.BIGQUERY); GoogleCredential credential = null; AssetManager am = this.getAssets(); InputStream inputStream = null; try { inputStream = am.open("hbhjb-8f79f6642470.p12"); } catch (IOException e2) { e2.printStackTrace(); } File file = createFileFromInputStream(inputStream, this); try { credential = new GoogleCredential.Builder().setTransport(TRANSPORT) .setJsonFactory(JSON_FACTORY) .setServiceAccountId("projectnum-******************* 3ee3130770087ceab09a482173@developer.gserviceaccount.com ") .setServiceAccountScopes(SCOPES) .setServiceAccountPrivateKeyFromP12File(file) .build(); } catch (GeneralSecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Bigquery bigquery = new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential) .setApplicationName("BigQuery-Service-Accounts/0.1") .setHttpRequestInitializer(credential).build(); TableRow data = new TableRow(); data.set("callerNumber", "123456789"); TableDataInsertAllRequest.Rows row = new TableDataInsertAllRequest.Rows(); row.setInsertId(System.currentTimeMillis()+""); row.setJson(data); TableDataInsertAllRequest requests = new TableDataInsertAllRequest(); requests.setRows(Arrays.asList(row)); TableDataInsertAllResponse response = null; try { response = bigquery.tabledata().insertAll("projectNum", "Data", "CallersData", requests).execute(); Log.d("big query response", response.toString()); } catch (IOException e) { e.printStackTrace(); } for (TableDataInsertAllResponse.InsertErrors err: response.getInsertErrors()) { for (ErrorProto ep: err.getErrors()) { Log.e("error",ep.getReason() + " : " + ep.getMessage() + " at " + ep.getLocation()); } } } 

now the problem is that I get an IO exception when inserting ie data into this line

  response = bigquery.tabledata().insertAll("projectNum", "Data", "CallersData", requests).execute(); 

I am trying to resolve this in the last 2 days. If someone here successfully implemented it, please help me find the problem.

Thanks in advance.

Below is the stacktrace table

 result = { java.io.IOException@830026649024 } Method threw 'java.io.IOException' exception. cause = { java.io.IOException@830026649024 } "java.io.IOException" detailMessage = null stackState = null stackTrace = {java.lang.StackTraceElement[30]@830026473856} suppressedExceptions = { java.util.Collections$EmptyList@830023143656 } size = 0 
+3
source share
1 answer

Try using the same code inside another thread or Asynctask. Let me know if you are still facing any problem.

+1
source

Source: https://habr.com/ru/post/1213533/


All Articles