Harry Sharma Harry Sharma - 1 year ago 59
Android Question

IO exception while inserting data in table on Big Query

I am trying to insert data in a table on big query.I followed few docs and my final code looks like

HttpTransport TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
List<String> SCOPES = Arrays

GoogleCredential credential = null;
AssetManager am = this.getAssets();
InputStream inputStream = null;
try {
inputStream = am.open("hbhjb-8f79f6642470.p12");
} catch (IOException e2) {

File file = createFileFromInputStream(inputStream, this);

try {
credential = new GoogleCredential.Builder().setTransport(TRANSPORT)
} catch (GeneralSecurityException e) {
} catch (IOException e) {

Bigquery bigquery = new Bigquery.Builder(TRANSPORT, JSON_FACTORY, credential)

TableRow data = new TableRow();
data.set("callerNumber", "123456789");

TableDataInsertAllRequest.Rows row = new TableDataInsertAllRequest.Rows();
TableDataInsertAllRequest requests = new TableDataInsertAllRequest();

TableDataInsertAllResponse response = null;
try {
response = bigquery.tabledata().insertAll("projectNum", "Data", "CallersData", requests).execute();
Log.d("big query response", response.toString());
} catch (IOException e) {

for (TableDataInsertAllResponse.InsertErrors err: response.getInsertErrors()) {
for (ErrorProto ep: err.getErrors()) {
Log.e("error",ep.getReason() + " : " + ep.getMessage() + " at " + ep.getLocation());

now tthe problem is that i am getting IO exception while inserting data i.e on this line

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

I am trying to resolve this from last 2 days.If anyone here has implemented it successful please help me to find the issue.

Thanks in advance.

Following is the stacktrace

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

Answer Source

Try using the same code inside a different thread or a Asynctask. Let me know if you still face any issue.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download