Java calling Oracle Update statement [message #203768] |
Thu, 16 November 2006 04:37 |
SaraC
Messages: 81 Registered: August 2005
|
Member |
|
|
I need to update a column in my database via the Java code.
I am using this code
connection = getConnection();
connection.setAutoCommit(false);
stmt = connection.createStatement();
stmt.execute("UPDATE ORG_CFG " + "SET subset_id = '624001000027134' " + "WHERE ORGANISATION_id = '5082'");
However, the database is not updated and a later select returns null because the value is not updated.
I have tried to use a SELECT statement and a value is returned so its not the connection - it seems something is wrong with the UPDATE.
Can anyone help?
Thx
Update
I removed the autocommit and it worked but wouldnt rollback the transaction like I wanted since it was auto committed. With autocommit false it didnt seem to set the value before the rollback. With autocommit true it didnt rollback. So Ive removed autocommit updated the value the updated again to reset to null. Solved.
Thanks
[Updated on: Thu, 16 November 2006 05:03] Report message to a moderator
|
|
|
|
Re: Java calling Oracle Update statement [message #204528 is a reply to message #203768] |
Tue, 21 November 2006 03:08 |
SaraC
Messages: 81 Registered: August 2005
|
Member |
|
|
Thanks for that - I found out what the problem was.
The auto commit false didnt seem to set it at all - if I put autocommit true it committed it and didnt rollback like I needed. So I set auto commit to true - updated to hold the value, did what I need to then did another update to remove the value. It seemed to work that way.
Thanks for your suggestion though.
|
|
|