This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Customer Requirements for Developers and have Marcho Behler on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes JDBC insert record Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC insert record" Watch "JDBC insert record" New topic

JDBC insert record

Minh Phan

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
author & internet detective

Joined: May 26, 2003
Posts: 32328

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.

[OCA 8 book] [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.

I agree. Here's the link:
subject: JDBC insert record
It's not a secret anymore!