File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and Relational Databases and the fly likes Problems in inserting data to MS Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problems in inserting data to MS Access Database" Watch "Problems in inserting data to MS Access Database" New topic
Author

Problems in inserting data to MS Access Database

Ashok Pradhan
Ranch Hand

Joined: Dec 17, 2007
Posts: 180

I have a table named Questions
Columns are:-
Columns DataType
ID -AutoNumber
QUESTION -Memo
OPTION_A -Memo
OPTION_B -Memo
OPTION_C -Memo
OPTION_D -Memo
EXPLANATION -Memo
POS_MARK - Number

This is my program to insert some value in question Table (Yes I have created DSN named QuizExam)
but this generate an error:-

Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'What is your Name'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3110)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
at AccessConn.main(AccessConn.java:58)

Process completed.




Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

Use a PreparedStatement, they are far superior to Statements and would likely resolve what looks like a data encoding issue (you didn't put quotes around the values).


[OCA 8 Book] [Blog]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problems in inserting data to MS Access Database
 
It's not a secret anymore!