title: Exception in thread "main" java.sql.SQLException: near "s": syntax error
body: <p>I wrote a program that populates a database with a list of words. Problem is, it throws up the "Exception in thread "main" java.sql.SQLException: near "s": syntax error" every time I try to run the code. I realize similar questions have been asked on this forum, but in the context of MY code I am unable to rectify the error.</p>
  
  <p>Thus I turn to you for help.</p>
  
  <p>This is the code</p>
  
  <pre><code>import java.io.*;
  import java.sql.*;
  import java.util.Scanner;
  
  public class db_populate {
  
      public static void main(String[] args) throws SQLException, IOException,
              ClassNotFoundException {
          Connection c = null;
          Statement stmt = null;
          Scanner in = null;
          String word;
          String wordcat;
          String j, sql;
          int i = 0;
  
          Class.forName("org.sqlite.JDBC");
          c = DriverManager.getConnection("jdbc:sqlite:dictionary.db");
          c.setAutoCommit(false);
          System.out.println("Opened database successfully");
  
          stmt = c.createStatement();
  
          in = new Scanner(new File("wordsEn.txt"));
  
          while (in.hasNext()) {
              word = in.nextLine();
              i++;
              j = Integer.toString(i);
              wordcat = word.substring(0, 2);
              sql = "INSERT INTO WORDS (ID,CAT,WORD) " + "VALUES(" + j + ",'"
                      + wordcat + "','" + word + "');";
              stmt.executeUpdate(sql);
          }
  
          stmt.close();
          c.commit();
          c.close();
          in.close();
          System.out.println("Records created successfully");
      }
  
  }
  </code></pre>
  
  <p>and these are the errors I get when I run.</p>
  
  <pre><code>Opened database successfully
  Exception in thread "main" java.sql.SQLException: near "s": syntax error
      at org.sqlite.core.NativeDB.throwex(NativeDB.java:397)
      at org.sqlite.core.NativeDB._exec(Native Method)
      at org.sqlite.jdbc3.JDBC3Statement.executeUpdate(JDBC3Statement.java:116)
      at db_populate.main(db_populate.java:34)
  </code></pre>