title: How to insert values from csv into database in java
body: <p>I have tried the following code to split the csv values and now how do insert it in to DB? Do I have save the values in to separate variables to match column names? I am unable to figure out.</p>
  
  <p>Note: I don't want to use any csv parser right now. I just want to do it manually</p>
  
  <pre><code>public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
          String name;
          String email;
          String phone;
          String ID;
  
          Connection con = OracleDBConnection.getConnection();
          String query = "Insert into NEWSTUDENT values(?,?,?,?)";
                  PreparedStatement st = con.prepareStatement();
                  st.executeUpdate(query);        
  
          try {
              BufferedReader bReader = new BufferedReader(new FileReader("1000rows.csv"));
  
              while (bReader != null) {
                  String read;
                  try {
                      read = bReader.readLine();
                      if (read != null) 
                      {
                          String[] array = read.split(",+");
                          for(String result:array)
                          {
                              System.out.println(result);
                          }
                      } 
                  } catch (IOException ex) {
                      ex.printStackTrace();
                  }
                  finally
                  {
                     if (bReader == null) 
                      {
                          bReader.close();
                      }
                  }
              }
          } catch (FileNotFoundException ex) {
              ex.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>output: </p>
  
  <pre><code>1Kiriti
  kiriti@gmail.com
  880789939
  </code></pre>
  
  <p>Column names in Database:</p>
  
  <pre><code>Name Email Phone ID
  </code></pre>