|
Home > Archive > PostgreSQL JDBC > December 2005 > problems with currval and rollback
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
problems with currval and rollback
|
|
| Assad Jarrahian 2005-12-22, 8:25 pm |
| Hi all,
So I started to make some changes with my jdbc code here and there
(nothing to do with the relevant lines) and suddenly currval and
rollback don't work.
try{
db. setAutoCommit(false)
;
addLM.setInt(1, lm.getOrigin());
.......
addLM.executeUpdate();
sql = db.createStatement();
ResultSet result = sql.executeQuery("SELECT
currval('lm_id_seq')
;");
if (result. next()){
db.commit();
db. setAutoCommit(true);
else{
db.rollback(); //reverse all changes
db. setAutoCommit(true);
}
catch(SQLException ex){
try {
db.rollback();
db. setAutoCommit(true);
} catch (SQLException e) {
throw e;
}
throw ex;
}
What happens is that the it inserts a db, but cannot get a value back
using currval (ERROR: ERROR: currval of sequence "lm_id_seq" is not
yet defined in this session 55000 ) , yet the db gets the addlm
inserted. It should rollback, but it does not. What gives?
I ran the insert-currval combo from psql and it worked.
What gives?
Any help would be appreciated.
-assad
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
| |
| Oliver Jowett 2005-12-23, 3:24 am |
| Assad Jarrahian wrote:
> Hi all,
> So I started to make some changes with my jdbc code here and there
> (nothing to do with the relevant lines) and suddenly currval and
> rollback don't work.
We really need a selfcontained testcase, especially since it sounds like
the problem depends on the exact logic you're executing, not just the
update/currval bit.
-O
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
|
|
|
|
|