开发者

Failing jdbc INSERT INTO statement to MS Access database

statement.executeUpdate("INSERT INTO countrylookup (Country, DialCode) VALUES('Iran', '957')")

Running this statement gives me no error output in the console, but when I check the database no update/insert is made. What could be the reason for this?

The access to the database itself is successful, and fetching values with a statement such as SELECT * FROM countrylookup succeeds.

I tried the preparedStatement approach aswell with the exact same result. The file is not open when I execute the command.

UPDATE: Stacktrace: (first row in Swedish means "INSERT INTO-expression contains the following unknown fieldname: 'Pa_RaM000'. Please check that the name is rightly spelled and try again.)

Exception in thread "main" java.sql.SQLException: [Microsoft][Drivrutin f?r ODBC Microsoft Access] INSERT INTO-uttrycket inneh?ller f?ljande ok?nda f?ltnamn: 'Pa_RaM000'. Kontrollera att namnet ?r r?ttstavat och f?rs?k igen.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeUpdate(Unknown Source)
at MDBAccessor.insertValueIntoField(MDBAccessor.java:43)
at TestRunner.main开发者_运维问答(TestRunner.java:28)


Is dialcode numeric? If so, remove the quotes from the value.

VALUES('Iran', 957)


In order for the INSERT INTO statement to actually be reflected in the database you have to call connection.commit() followed by connection.close(). Another similar thread describing this: Java General Error On Insert...???

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜