Results 1 to 5 of 5
  1. #1
    javamula is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default Lexical error at line 1, column 32.

    Dear All,

    Please help what is going on when running the project...

    here is the error message:
    run:
    INSERT INTO CURRENCY VALUES ("AFN','Afghanistan Afghanis',47.6326566391,0.0209940001)
    Exception in thread "main" java.sql.SQLSyntaxErrorException: Lexical error at line 1, column 32. Encountered: "\ufeff" (65279), after : "".

    When executing the following code...
    Java Code:
    static void insertTable(String tableName, String datName, Statement stmt)
                throws SQLException, IOException {
          BufferedReader in = new BufferedReader(new FileReader(datName +".dat"));
           String line;
          while ((line = in.readLine())!= null)
          {
    
          String command = "INSERT INTO  " +tableName +" VALUES  (" +line +")";
    thank you for your kind help in this matter....

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Try passing the statements through a PreparedStatement instead.

  3. #3
    javamula is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default Lexical being solved by PreparedStatement..

    Dear r035198x,
    thank you for the advice. Case closed now.
    but why only insert the ROW 1,3,5... while the ROW 2,4,6...being skipped in readLine()
    Java Code:
    static void insertTable(String tableName, String datName, Statement stmt, Connection conn) throws SQLException, IOException {
        
            String sql = "INSERT INTO CURRENCY VALUES (?,?,?,?)";
            PreparedStatement dataUpdate = conn.prepareStatement(sql);
            BufferedReader in = new BufferedReader(new FileReader(datName +".dat"));
            String line;
            String[] tokens = {null,null,null,null};
            while ((line = in.readLine())!= null){
            tokens = line.split(",");
            dataUpdate.setString(1, tokens[0]);
            dataUpdate.setString(2, tokens[1]);
            dataUpdate.setDouble(3, Double.valueOf(tokens[2]).doubleValue()); 
            dataUpdate.setDouble(4, Double.valueOf(tokens[3]).doubleValue()); 
            //stmt.executeUpdate("INSERT INTO CURRENCY VALUES ('ALL','Albania Leke',92.29,0.0108354101)");
            dataUpdate.executeUpdate();
            dataUpdate.clearParameters();
            line = in.readLine(); //read next line
            }
      }
    TQ for the help...

  4. #4
    javamula is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default

    Thank you for your kind attention...the case being solved by disabling the last row of the code:

    line = in.readLine(); //read next line

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by javamula View Post
    Dear r035198x,
    thank you for the advice. Case closed now.
    ..
    [/CODE]

    TQ for the help...
    Welcome, make sure you close all those connections in a finally block though.

Similar Threads

  1. insert row and column and delete row and column
    By daredavil82 in forum New To Java
    Replies: 13
    Last Post: 09-22-2011, 07:10 PM
  2. column footer Line at iReport
    By gustio in forum New To Java
    Replies: 2
    Last Post: 12-02-2008, 01:49 PM
  3. Display Line# and Column# in JSP
    By loganathan.lakshmanan in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 01-17-2008, 01:37 PM
  4. Error: javax.servlet.ServletException: Column not found
    By barney in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 08:20 AM
  5. Help with Lexical units, use hashmap
    By zoe in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 07:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •