tags:

views:

207

answers:

2

I'm trying to get insert ID while after inserting some data in my database.

String sql = "INSERT INTO ADI.DUMMY(dummy_data) VALUES('from database logger')";
PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
int extUptReturn = ps.executeUpdate(sql);

But I got this exception:

Java exception: ''java.lang.UnsupportedOperationException''; 
    thrown from class name: ''sun.jdbc.odbc.JdbcOdbcConnection'', method name: ''prepareStatement'', file: ''JdbcOdbcConnection.java'', line: '1762'   
A: 

MAy be the JDBC implementation could not be supporting the sepcific opration. CHeck the JDBC driver used.

Sreejesh
+4  A: 

The ODBC bridge driver doesn't support it. Nothing to do against. Either replace the driver or live with it. I would just use a real JDBC driver instead of the poorly-developed, feature-lacking, bug-rich Sun ODBC bridge driver. Almost all self-respected server based RDBMS vendors provides a fullworthy JDBC driver for download at their homepage. Just Google "[vendorname] jdbc driver download" to find it. Here's an overview:

Only for MS-Access --which actually isn't a server based RDBMS at all-- you'll be forced to stick to ODBC bridge driver, unless you agree to pay for the HXTT JDBC driver.

BalusC
-1 for unnecessary Access bashing. The reason why there isn't a driver for it is not because it's not an RDBMS, but because it's not a server database engine and shouldn't be used as a data store in the contexts in which JDBC is in use. Of course, I'm one of thos who believes Java has no place on the client...
David-W-Fenton
@David: I didn't bash Access, I bashed the JDBC-ODBC bridge driver.
BalusC
You said Access "isn't a fullfledged RDBMS". That's bashing Access, period, end of statement, no ambiguities whatsoever, and is only true if you have a WRONG definition of RDMBS. You lessened the quality of your answer by including it. You could delete that phrase and it wouldn't change the advice you give one iota.
David-W-Fenton
@David: I should indeed maybe have added "server" behind "RDBMS" to clarify the bit a bit more. Thank you for the nitpick and sorry that it wasn't clear to you at first glance.
BalusC
Then you don't need RDBMS, just "Jet/ACE is not a database server". And I'm the first to suggest that it's probably not appropriate for most Java-based apps for that reason. That is, it's inappropriate not because it's not an RDBMS (for some definition of RDBMS), but that it's not a *server* database engine, as you say. Why not edit, and I'll back out my downvote.
David-W-Fenton
BTW, it occurs to me that it may be possible to get to Jet/ACE data via the SQL Server driver, after having set up your Jet/ACE database as a linked server...
David-W-Fenton
@David: There, I put "server based" in.
BalusC
I tried to reverse my downvote based on your edit, but it's too old to allow me to do so. Thanks for taking the time to edit.
David-W-Fenton