mysql - How to make this JDBC code more portable? -


i have following piece of code:

list<list<object>> batch = db.executeinsert("insert batches (batch_date,source,log_file,status) values (?, ?, ?, ?)",      now,      importzip.getabsolutepath(),      logfile.getabsolutepath(),      batchstatus.importing.tostring()) 

and returned data when run on mysql returns integer representing inserted id expected. when run under oracle returns non portable rowid object. have identity column, converted sequence represents id. however, there's not can rowid.

i've checked code , i'm calling statement.getgeneratedkeys() thought whole point of making portable code. how can write in portable fashion without executing things select table rowid=? not portable.

as found out, oracle returns rowid can - example - obtain id querying row.

some databases return last generated id (which might not belong table, eg mysql afaik), databases return id column first column in resultset, others return all columns (eg postgresql, firebird default) position of id column might not first depends on column order in table.

the real option create database specific strategy knows rules obtain right column. might involve firing off query oracle, having heuristic find primary key column postgresql , firebird, etc.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -