title: Importing csv data from Storage to Cloud SQL not working - status always "pending"
body: <p>I am new to java (I have experience with <code>C#</code> though)</p>
  
  <p>Sadly, I inherited a terrible project (the code is terrible) and what I need to accomplish is to import some csv files into Cloud SQL</p>
  
  <p>So there's a WS which runs this task, apparently the dev followed <a href="https://cloud.google.com/sql/docs/mysql/admin-api/v1beta4/instances/import#examples" rel="nofollow noreferrer">this guide</a> to import data. But it is not working. Here's the code (Essential parts, actually it is longer and more ugly)</p>
  
  <pre><code>    InstancesImportRequest requestBody = new InstancesImportRequest();
          ImportContext ic = new  ImportContext();
          ic.setKind("sql#importContext");
          ic.setFileType("csv");
          ic.setUri(bucketPath);
          ic.setDatabase(CLOUD_SQL_DATABASE);
          CsvImportOptions csv = new CsvImportOptions();
          csv.setTable(tablename);
          List&lt;String&gt; list = new ArrayList&lt;String&gt;();
          // here there is some code that populates the list with the columns
          csv.setColumns(list);
          ic.setCsvImportOptions(csv);
          requestBody.setImportContext(ic);
  SQLAdmin sqlAdminService = createSqlAdminService();
       SQLAdmin.Instances.SQLAdminImport request = sqlAdminService.instances().sqladminImport(project, instance, requestBody);
      Operation response = request.execute();
      System.out.println("Executed : Going to sleep.&gt;"+response.getStatus());
          int c = 1;
          while(!response.getStatus().equalsIgnoreCase("Done")){
              Thread.sleep(10000);
              System.out.println("sleeped enough &gt;"+response.getStatus());
              c++;
              if(c==50){
                  System.out.println("timeout?");
                  break;
              }
          }
  public static SQLAdmin createSqlAdminService() throws IOException, GeneralSecurityException {
          HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
          JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  
          GoogleCredential credential = GoogleCredential.getApplicationDefault();
          if (credential.createScopedRequired()) {
            credential =
                credential.createScoped(Arrays.asList("https://www.googleapis.com/auth/cloud-platform"));
          }
  
          return new SQLAdmin.Builder(httpTransport, jsonFactory, credential)
              .setApplicationName("Google-SQLAdminSample/0.1")
              .build();
        }
  </code></pre>
  
  <p>I am not quite sure how response should be treated, it seems it is an async request. Either way, I always get status <code>Pending</code>; it seems it is not even start to executing.</p>
  
  <p>Of course it ends timing out. What is wrong here, why the requests never starts ? I couldn't find any actual example on the internet about using this java sdk to import files, except the link I gave above</p>