| Author |
Syntax error in INSERT INTO statement
|
andy iott
Greenhorn
Joined: Sep 23, 2004
Posts: 3
|
|
Hi- I am writing a java app that interfaces an Access 2000 DB via JDBC-ODBC. I keep getting a syntax error on the following sql statement: String sql = "INSERT INTO REQUIREMENTS (DOC_ID, ORDER_DATE, ORDER_TYPE, CUST_CODE, CUST_NAME, CUST_ADDRESS_ST, CUST_ADDRESS_CITY, SPO_ORDER_NO, POCONTROL_NO, LIN_ITEM, CUST_PART_NO, OTHER_PART_NO, WTN, CUST_BINPART_NO, DESC, ORDER_NOTES, LIN_ITEM_NOTES, CUSTOMER) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; PreparedStatement stmt = con.prepareStatement(sql); pstmt.setString(1,docID); pstmt.setString(2,orderDate); pstmt.setString(3,orderType); pstmt.setString(4,custCode); pstmt.setString(5,shipToName); pstmt.setString(6,shipTo1); pstmt.setString(7,shipTo2); pstmt.setString(8,spoOrderNo); pstmt.setString(9,poNo); pstmt.setInt(10,Integer.parseInt(linNo)); pstmt.setString(11,gmPn); pstmt.setString(12,acdPn); pstmt.setInt(13,Integer.parseInt(qty)); pstmt.setString(14,custBin); pstmt.setString(15,desc); pstmt.setString(16,orderNotes); pstmt.setString(17,linNotes); pstmt.setString(18,cust); System.out.println(sql); pstmt.executeUpdate(); error produced: Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement. I have looked at this sucker for 2 days now. I can insert records for some fields if I limit the fields inserted to 6 or so, but I am unable to insert this entire statement and can find no correlation to what fields insert and which cause the syntax error. I have double checked that all data types correspond. I have also tried this with a Statement as well. Any feedback would be EXTREMELY appreciated. Thank you, AI
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
Did you try putting a space between "VALUES" and "("? Remember that Access isn't exactly the caviar of databases.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26201
|
|
Andy, I'm suprised the database lets you create a field named "DESC". I thought this was a reserved word. Does the query work without that field? Welcome to Javaranch! [edited to fix typo] [ September 23, 2004: Message edited by: Jeanne Boyarsky ]
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
|
Can you show some failing output with your System.out.println(sql);?
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
andy iott
Greenhorn
Joined: Sep 23, 2004
Posts: 3
|
|
It was the field name 'DESC'...I knew it was a stupid one!! At least it wasn't a space or "'"!!! I needed a fresh set of eyeballs. THANKS for the response guys.
|
 |
 |
|
|
subject: Syntax error in INSERT INTO statement
|
|
|