title: Exception: Operating System error code 3
body: <p>I am doing <strong>text file bulk upload</strong> in <strong>SQL Server</strong>. Whenever i tries to upload the files, gets Following Exception:</p>
  
  <blockquote>
    <p>[Microsoft] [ODBC SQL Server Driver] [SQL Server]Could not bulk insert
    because file 'C:/Form/Input_File/Form.txt' could not be opened.
    Operating System error code 3(The system cannot find the path
    specified).</p>
  </blockquote>
  
  <p>Please find the below code:</p>
  
  <pre><code>public void uploadFiles() 
      {
         File dir = new File(inputFilesPath);
                  String[] children = dir.list();
                  String completePathFileName = "";
                  System.out.println(" Inside Upload ::");
                  String saveFileNames = "";
                  PreparedStatement prepStat;
  
                  DBConnection  dbConnection=new DBConnection();
                  Connection conHandler= dbConnection.getConnection();    
                  if(null!=conHandler)        
                      System.out.println(" Clear ::"+conHandler);
  
                  try
                  {
                      if (children != null)
                      {
                          for (int i = 0; i &lt; children.length; i++) 
                          {
                              String filename = children[i];
      System.out.println(" children[i]::"+children[i]);
                              // File is validated based on some business rules.
                              if (isValidFile(filename) == 1)
                              {
                                  String[] fileSplit = filename.split("E");
                                  String[] extnSplit = fileSplit[1].trim().split(".TXT");
  
                                  completePathFileName += (completePathFileName.equals("")) 
                                  ? extnSplit[0] : "^" + extnSplit[0];
  
                                  saveFileNames += (saveFileNames.equals("")) 
                                      ? filename : "," + filename;
                                  System.out.println(extnSplit[0]);   
                              }
                              else
                              {
                                  inValidFileNames += (inValidFileNames.equals("")) 
                                  ? filename : ";\n" + filename;
                              }
                          }
  
                          if (!completePathFileName.trim().equals(""))
                          {
                              System.out.println(completePathFileName);
                              prepStat = conHandler.prepareStatement("Exec StartFileImport ?");
                              prepStat.setString(1, completePathFileName);
                              prepStat.execute();
                              saveFileNameToDatabase(saveFileNames);
                          }
  
                          }
                  }
                  catch (SQLException sql)
                  {
                      System.out.println(sql.getMessage());
                  }
  }
  </code></pre>
  
  <p>Getting Connection Object from the below code:</p>
  
  <pre><code>public Connection getConnection()
      {
          System.out.println("In side DB Connection...");
        try{
              //  get a database connection
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");  
              System.out.println("Before Driver");
              conn= DriverManager.getConnection("jdbc:odbc:form26qa","form26","form26");
              System.out.println("After Driver");
              if(conn != null)
              {
                  System.out.println("Connection established...");
  
              }//if
              else
              {
                  System.out.println("Connection failed...");
  
              }//else
        }//try
          catch(Exception e)
          {
              System.out.println("Exception ocurred..."+e);
              e.printStackTrace();
          }//catch
          return conn;
      }
  </code></pre>
  
  <p>Explanation:
  I am reading files from the input path and tried to get the fileName and file path and uploading file into SQL Server. </p>
  
  <p>Application is able to find the input file in the specified path. while uploading i am getting the above mentioned Exception</p>
  
  <p>Please check and suggest me to fix the issue.</p>