Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException. Generel Error

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a little code and your stack trace. Might be able to help a little more!
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
http://hsql.oron.ch/
Its also an open source project.
Have fun,
Frank

[This message has been edited by Frank Hale (edited June 02, 2000).]
 
Mejo Tom Vakanil
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Frank
 
Farooq Ali
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sabbir
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 http://www.javaranch.com/name.jsp . 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.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic