File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes SQLException. Generel Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "SQLException. Generel Error" Watch "SQLException. Generel Error" New topic

SQLException. Generel Error

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have a PreparedStatement in my servlet which can INSERT a record into a MS Access database.
PreparedStatement.executeUpdate() method throws SQLException.Generel error, when it tries to INSERT a record to the database when the database is not empty. It can only insert the record when the database (table in MS Access) has no record.
Any clue?
Gary Smith

Joined: Apr 03, 2000
Posts: 16
Are you INSERTing the same record and thus breaking any unique key criteria ?
What extra info do you get with the SQLException ? If you are using the JDBC-ODBC Bridge you can switch ODBC Tracing on (via the ODBC Administrator in Control Panel for that ODBC DSN).
Lori Battey
Ranch Hand

Joined: May 17, 2000
Posts: 37
How about a little code and your stack trace. Might be able to help a little more!

Lori Battey<br />SCJP2
Frank Hale
Ranch Hand

Joined: Mar 25, 2000
Posts: 230
MS ACCESS doesn't support PreparedStatements I got this information from PURE JAVA 2 by Kenneth Litwak. Using them will most likely produce the errors your getting. If ACCESS is all you have available then I would suggest getting a more full featured DBMS. I can suggest a very nice one called HypersonicSQL. Its a pure java dbms and is very fast.
Here is the link:
Its also an open source project.
Have fun,

[This message has been edited by Frank Hale (edited June 02, 2000).]
Mejo Tom Vakanil

Joined: Jun 06, 2000
Posts: 4
If i remember correctly, i have used preparedStatement to exe cute Queries in an MS-Access Database.
If you could send a stack trace of the error, this could help in a better suggestion.
I think you might have opened the particular table in your MS-Access GUI, before executing this query. Close all the tables from the MS-Access GUI and then try executing your application. Do reply if this works.
Frank Hale
Ranch Hand

Joined: Mar 25, 2000
Posts: 230
Pure Java 2 published by Sams says that MS Access doesn't support PreparedStatements, I'm not going to argue the point. Maybe your using Access 2000 which does? Who knows. I don't personnally use Access.
Farooq Ali
Ranch Hand

Joined: Sep 30, 2000
Posts: 43
well access doesn't support prepared statement
it treats it just like a statement call that is it is not precompiled sql but has to be compiled every time it is called thus negating the advantage of prepared statement
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, which you agreed to when you registered, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
I agree. Here's the link:
subject: SQLException. Generel Error
It's not a secret anymore!