title: To insert multiple rows in database (approx 100 in each column) after a condition becomes true
body: <p>Below is my code :
  In this all files from a folder a read one by one. In each file multiple keywords are searched. If the keyword is found then that is inserted into the database. </p>
  
  <pre><code>public class MyLogs {
  
      String folderPath="path to your folder";
      String filePath="";
      public void readLog() throws IOException{
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
          } catch (ClassNotFoundException e1) {
  
              e1.printStackTrace();
          }
  
          Connection connection = null;
          try {
              connection = DriverManager.getConnection(
                      "jdbc:oracle:thin:@localhost:dbName", "username", "password");
          } catch (SQLException e) {
              e.printStackTrace();
              return; }   
          FileInputStream inputStream = null;
          Scanner sc = null;
  
          try {
              File folder = new File("path to your folder");
  
              for (File  file : folder.listFiles()) {
                  if(file.isFile()){
                      filePath=folderPath+"\\"+file.getName();
                      String fileName=file.getName();
                      inputStream = new FileInputStream(filePath);
                      sc = new Scanner(inputStream, "UTF-8");
                      while (sc.hasNextLine()) {
                          String nextLine = sc.nextLine();
  
                          if (nextLine.contains("Status"))
                          {
                              String str=nextLine.substring(nextLine.lastIndexOf(" ")+1);
                              String str1=str.split(":")[0].replace("\'", "");
                                  String sql="INSERT INTO table"
                                      + "(columnName) VALUES"
                                      + "(?)";
                              PreparedStatement preparedStatement = connection.prepareStatement(sql);
                              preparedStatement.setString(1, str1);
                              preparedStatement .executeUpdate();
                          }
                          if(nextLine.contains("row"))
                          {
  
  
                              String str = nextLine.split(" ")[0];
                          //  System.out.println("\t\t\t\t\t\t\t\t\t"+str);
                              String sql="INSERT INTO table"
                                      + "(columnname) VALUES"
                                      + "(?)";
                              PreparedStatement preparedStatement = connection.prepareStatement(sql);
                              preparedStatement.setString(1, str);
                              preparedStatement .executeUpdate();
                          }
  
                              }
                  }
              }
                  if (sc.ioException() != null) {
                      throw sc.ioException();
                  }
  
          } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } finally {
              if (inputStream != null) {
                  inputStream.close();
              }
              if (sc != null) {
                  sc.close();
              }
          }
      }
      public static void main(String[] args) throws IOException {
          MyLogs ml=new MyLogs();
          ml.readLog();
      }
  }
  </code></pre>