title: Add ArrayList<String> to SQLite DB
body: <p>i´m writing my first program and trying to transfer data with an ArrayList (from a CSV database) to an SQLite database using JDBC Driver sqlite-jdbc-3.7.2.jar.
  I have already read <a href="http://www.tutorialspoint.com/sqlite/sqlite_overview.htm" rel="nofollow noreferrer">tutorials</a> für SQLite and java beginners and also different answers to questions on stackoverflow (<a href="https://stackoverflow.com/questions/3142285/saving-arraylist-in-sqlite-database-in-android">Link 1</a>,<a href="https://stackoverflow.com/questions/9052987/data-from-sqlite-into-arrayliststring">Link 2</a> ) and i can finally create a db with tables and variable columns (datatype: TEXT). But when i try to add record from an ArrayList to my testtable with this method:</p>
  
  <pre><code>/**
   * Add record from ArrayList&lt;string&gt; to table
   * @param selectTable (name of table)
   * @param line (List with record for table)
   */
  public void addRecord (String selectTable, ArrayList&lt;String&gt; line){
      try{
          //connect to database
          connection = new DBconnect(pathDataBase);
          database = connection.getConnection();
  
          //create SQL Statement
          ArrayList&lt;String&gt; columnNames = new ArrayList&lt;String&gt;();
          columnNames = getColumnList(selectTable); //call method to get all columnNames from selected table
  
          String sSQL = "INSERT INTO " + selectTable + "("; //update statement (string sSQL)
  
          //disperse ArrayList&lt;string&gt; columnNames in parts to add to the statement(string sSQL)
          int i = 0;
          for (i=0; i&lt;columnNames.size(); i++){
              sSQL = sSQL + columnNames.get(i);
              if (columnNames.size() + 1 &gt; i+2){
                  sSQL = sSQL + ", "; //update statement(string sSQL)
              }//end if
          }// end for
          sSQL = sSQL + ") VALUES("; //update statement(string sSQL)
  
          //disperse ArrayList&lt;string&gt; line in parts to add to the statement(string sSQL)
          i=0;
          for (i=0; i&lt;columnNames.size(); i++){
              sSQL = sSQL + line.get(i); //add record per line in columns
              if (columnNames.size() + 1 &gt; i+2){
                  sSQL = sSQL + ", ";
              }//end if
          }//end for
          sSQL = sSQL + ");";
          System.out.println(sSQL);
  
          Statement statement = database.createStatement();
          System.out.println("created statement");
          statement.executeUpdate(sSQL);
          System.out.println("executed Update");
  
          statement.close();
          database.close();
          //catch exception
      } catch ( Exception e ) {
          System.err.println( e.getClass().getName() + ": " + e.getMessage() );
          System.exit(0);
      }//end try/catch
  }//end method
  </code></pre>
  
  <p>i get the following exception description:</p>
  
  <pre><code>Opened database successfully
  INSERT INTO Testtable(Test1, Test2, Test3) VALUES(Hallo1, Hallo2, Hallo3); //(ArrayList&lt;string&gt; columnNames) (ArrayList&lt;string&gt; line)
  created statement
  java.lang.NullPointerException: null
  </code></pre>
  
  <p>I think something in my String "sSQL" has to be wrong. </p>
  
  <p>Does someone know what i have to change in order to make it work?
  Can i not write the datatype "string" in a "Text" column? </p>
  
  <p>I hope i described my problem understandable and asked the right questions.</p>
  
  <p>Many thanks in advance. :)</p>
  
  <p>@all: Oh man, i stumbled over my own stupidity. I opened a connection to database and call a method, which opens also a connection and closes it. of course now i can´t execute a statement, because my database is closed. Thanks Naren for your time!!! </p>