 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Paul Cooper Guest
|
Posted: Wed Nov 10, 2004 11:38 am Post subject: PreparedStatement, ACCESS and jdbcodbc |
|
|
Dear All,
I have a situation where I am using MS Access as the database package
for an application I am developing. This is an interim situation for
development only - I will be moving it to PostgreSQL in due course,
but cannot at present. I am using the JdbcOdbc driver, with the
connection set up as follows:
//
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbUrl = "jdbc:odbc:Driver={MicroSoft Access
Driver(*.mdb)};DBQ=C:/femgis/fm.mdb";
String user = "";
String pass = "";
Class.forName(driverName);
Connection dbConn = DriverManager.getConnection(dbUrl, user, pass);
This connection works fine in all other contexts I am using it in.
Anyway, I am executing an insert statement to generate records that
include an key automatically generated by the DBMS. I would like to
retrieve the key for further processing.
First, my INSERT statement works fine using Statement.execute(String).
However, I can find no means of returning the autogenerated value!
I have tried using
Statement.execute(String,Statement.RETURN_GENERATED_KEYS), followed by
Resultset rs = myStatement.getGeneratedKeys(), and various attemtps
with preparedStatements, for example:
myStmt.execute(sqlString,Statement.RETURN_GENERATED_KEYS);
ResultSet thisRs = myStmt.getGeneratedKeys();
System.out.println(thisRs.getString(1));
but every time I get the following stack trace:
java.lang.UnsupportedOperationException
at
sun.jdbc.odbc.JdbcOdbcStatement.getGeneratedKeys(JdbcOdbcStatement.java:1460)
at
FeLocationForm$okButtonListener.actionPerformed(FeLocationForm.java:599)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
Is what I am attempting simply impossible with the development set up
I am using? Is it a consequence of the JdbcOdbc bridge, and if so is
there a better JDBC driver for Access (free, as I have no need to
build this into my final solution)?
Many thanks
Paul
|
|
| Back to top |
|
 |
Paul Cooper Guest
|
Posted: Wed Nov 10, 2004 11:45 am Post subject: Re: PreparedStatement, ACCESS and jdbcodbc |
|
|
Sorry - should have said I am using Java version 1.4.1_01
Paul
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|