File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes count field incorrect error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "count field incorrect error" Watch "count field incorrect error" New topic

count field incorrect error

Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
I have created an Access database, with a "Users" table with fields: "personname", "surname", "email", "username", "password", "secretQuestion", "answer".
I am getting a count field incorrect error when i process this:

Please tell me if I did something wrong here, because I don't know and I am ready to
Paul Clapham

Joined: Oct 14, 2005
Posts: 18121

You did two things wrong, actually.

First, your SQL INSERT statement doesn't use the correct syntax. Look here for a page which describes the correct syntax. (You didn't use parentheses.)

Second, constructing an SQL statement that way is error-prone and risky. For one thing, if any of the string values contain quotes -- and they could -- then the result is not valid SQL. And for another thing, it's possible for evil users to uses that statement for "SQL Injection" attacks; humorous example here.

The cure for both of those problems is to use PreparedStatement; you should find that in any reputable JDBC tutorial.
Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
Thanks alot guys, I appreciate the help alot. I am using PreparedStatement now aswell as MySQL server. I was having endless issues with MS Access and Win 7 64-bit aswell. Everything is working 100%.
I agree. Here's the link:
subject: count field incorrect error
Similar Threads
Trouble calling stored procedure from a servlet
Error while inserting data into from a JSP Page
Executing a stored procedure from a servlet
How to Insert Data into a table in mysql database
help needed in makin GUI (in netbeans) for a maths program(with lots of loops).