N
Neil Barnwell
Hi, all.
I'm using Java and JDBC to connect to an Access database. This is only a
sample application I'm writing to get used to things (I'm moving to SQL
Server once I get round to bringing the disk home lol).
The thing I want to know is, how do I find out what the new value of an
autonumber field is when I add a new record?
I have a table:
empno - autonumber
surname - text
forename - text
deptno - text
I've tried using various combinations of:
"Statement.executeUpdate(String arg0, int[] arg1)",
"Statement.getGeneratedKeys()",
"Statement.getRecordSet()".
but all to no avail - I get "java.lang.UnsupportedOperationException". Is
this because Access or the "sun.jdbc.odbc.JdbcOdbcDriver" JDBC driver I'm
using don't support this? Does SQL Server or Oracle support something like
this? I know that in Oracle there's no such thing, and that the only way to
replicate an autonumber field is to have a bit of PL/SQL in a trigger, but
it's the java bit that I'm stuck on.
Either I'm on the wrong track, or I'm not implementing this correctly,
either way - I could do with your help.
Cheers,
<Barney />
I'm using Java and JDBC to connect to an Access database. This is only a
sample application I'm writing to get used to things (I'm moving to SQL
Server once I get round to bringing the disk home lol).
The thing I want to know is, how do I find out what the new value of an
autonumber field is when I add a new record?
I have a table:
empno - autonumber
surname - text
forename - text
deptno - text
I've tried using various combinations of:
"Statement.executeUpdate(String arg0, int[] arg1)",
"Statement.getGeneratedKeys()",
"Statement.getRecordSet()".
but all to no avail - I get "java.lang.UnsupportedOperationException". Is
this because Access or the "sun.jdbc.odbc.JdbcOdbcDriver" JDBC driver I'm
using don't support this? Does SQL Server or Oracle support something like
this? I know that in Oracle there's no such thing, and that the only way to
replicate an autonumber field is to have a bit of PL/SQL in a trigger, but
it's the java bit that I'm stuck on.
Either I'm on the wrong track, or I'm not implementing this correctly,
either way - I could do with your help.
Cheers,
<Barney />