| Author |
JDBC insert record
|
Minh Phan
Greenhorn
Joined: Sep 23, 2004
Posts: 8
|
|
After connecting the Access database, try to insert a record and an error message is displayed: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Invalid attribute/option identifier. Why use the commented out lines it is OK? Please help. Here is the code: [edited to disable smilies and add code tags] [ October 05, 2004: Message edited by: Jeanne Boyarsky ]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
Minh, Welcome to JavaRanch! I suggest using a prepared statement instead of a statement. That takes care of the formatting for you. Check whether the table is defined using the columns in the same order as are in your SQL insert. Or better yet, add the column names explicitly to the SQL.
|
[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
|
 |
Ramaswamy Srinivasan
Ranch Hand
Joined: Aug 31, 2004
Posts: 295
|
|
Hi Minh Welcome to Javaranch. Sure you will have a great time Ranching here
I suggest using a prepared statement instead of a statement
I too second the strong recommendation of prepared statement. It is compiled once and then can be reused. When u want to add some performance measures to your code, you go for the PreparedStatement. You have quite a good time...using that. Simple and effecient enough. And did u try the query at the DB console? Did it work properly?Try this out and if trouble still persists, you know where to get back. Cheers, Swamy
|
 |
 |
|
|
subject: JDBC insert record
|
|
|