• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC insert record

 
Minh Phan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic