Results 1 to 5 of 5
- 10-02-2009, 05:11 PM #1
Member
- Join Date
- Sep 2009
- Posts
- 22
- Rep Power
- 0
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...thank you for your kind help in this matter....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 +")";
- 10-02-2009, 07:13 PM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Try passing the statements through a PreparedStatement instead.
- 10-03-2009, 05:49 PM #3
Member
- Join Date
- Sep 2009
- Posts
- 22
- Rep Power
- 0
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()
TQ for the help...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 } }
- 10-03-2009, 06:27 PM #4
Member
- Join Date
- Sep 2009
- Posts
- 22
- Rep Power
- 0
Thank you for your kind attention...the case being solved by disabling the last row of the code:
line = in.readLine(); //read next line
- 10-05-2009, 10:12 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
Similar Threads
-
insert row and column and delete row and column
By daredavil82 in forum New To JavaReplies: 13Last Post: 09-22-2011, 06:10 PM -
column footer Line at iReport
By gustio in forum New To JavaReplies: 2Last Post: 12-02-2008, 12:49 PM -
Display Line# and Column# in JSP
By loganathan.lakshmanan in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 01-17-2008, 12:37 PM -
Error: javax.servlet.ServletException: Column not found
By barney in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 08-07-2007, 07:20 AM -
Help with Lexical units, use hashmap
By zoe in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 06:14 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks