title: SQLite Java JDBC Insert
body: <p>Following is my Java code. In linux, it is working fine but in Windows I'm unable to insert data into the database on local disk. In NetBeans get it all right but <code>.jar</code> file not. JDBC driver see be good.</p>
  
  <p>Connecting to database:</p>
  
  <pre><code>public static Connection connectToDb() {
      try {
          Connection connection = null;
          DriverManager.registerDriver(new org.sqlite.JDBC());
          //LINUX PATH
          if (OSDetector.isLinux()) {
              connection = DriverManager.getConnection("jdbc:sqlite:/home/" + userNameLinux + "/PDFMalwareDataAnalyser/DatabaseSQLite/database.db", NAME, PASSWORD);
              //WINDOWS PATH 
          } else {
              connection = DriverManager.getConnection("jdbc:sqlite:C:\\PDFMalwareDataAnalyser\\DatabaseSQLite\\database.db", NAME, PASSWORD);
          }
          connection.setAutoCommit(true);
          if (connection != null) {
              System.out.println("Otvorená.");
          }
          return connection;
      } catch (SQLException e) {
          System.err.println(e.getClass().getName() + e.getMessage());
          //  System.exit(0);
      }
      return null;
  }
  </code></pre>
  
  <p>Insertion:</p>
  
  <pre><code>public void insertDataToDatabase(int idReport) throws SQLException {
      connection = new SQLiteJDBC().connectToDb();
      PreparedStatement insertCommunication = connection.prepareStatement("insert into table_communication values(?,?);");
      insertCommunication.setString(2, communicationsFinal.toString());
      try {
          insertCommunication.executeUpdate();
      } catch (Exception e) {
          e.printStackTrace();
      }
      insertCommunication.close();
      connection.close();
      System.out.println("1. --- Insert do tabuľky TABLE_COMMUNICATION OK ---");
  }
  </code></pre>