wood burning stoves 2.0*
The moose likes JDBC 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problems in inserting data to MS Access Database" Watch "Problems in inserting data to MS Access Database" New topic

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
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
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704

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).

My Blog: Down Home Country Coding with Scott Selikoff
I agree. Here's the link: http://aspose.com/file-tools
subject: Problems in inserting data to MS Access Database