Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JDBC/MSAccess update question

0 views
Skip to first unread message

Darrel Riekhof

unread,
Jan 25, 1998, 3:00:00 AM1/25/98
to

I'm just getting started with JDBC and Access--must say that it's been a
pleasant suprise how easy everything has been so far. But, I need some help.

I'm trying to update a table (my Customer table). One of the columns in this
table is the ID (Customer Id number). It's the key, and it is an
autonumber--Access automatically increments it to the next available integer for
each new record. How do I specify this in Java JDBC code? I've tried just not
including the field in the SQL update statement but I got an exception:

java.sql.SQLException: [Microsoft][ODBC Microsoft Access 97 Driver] Number of
query values and destination fields aren't the same.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:3669)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3822)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:1063)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:214)
at
sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:171)
at CustomerInsert.insert(CustomerInsert.java:63)

Would a good approach be to query for the biggest CustID# first and then
increment it, or is there an eaiser way?

Also, I'm a little green on DB design and programming. What's a good way to
ensure Customer's don't get inserted more than once?
--
Darrel Riekhof
FerretTronics--Servo Control Chips and Software
http://www.busprod.com/ferrettronics/

0 new messages