Home » Developer & Programmer » JDeveloper, Java & XML » Java calling Oracle Update statement
Java calling Oracle Update statement [message #203768] Thu, 16 November 2006 04:37 Go to next message
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 #204375 is a reply to message #203768] Mon, 20 November 2006 06:59 Go to previous messageGo to next message
mnrnjn
Messages: 61
Registered: November 2006
Location: india
Member
stmt.execute("UPDATE ORG_CFG " + "SET subset_id = '624001000027134' " + "WHERE ORGANISATION_id = '5082'");

Use

int i = stmt.executeUpdate(query);

hope it helps
bye
Re: Java calling Oracle Update statement [message #204528 is a reply to message #203768] Tue, 21 November 2006 03:08 Go to previous message
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.
Previous Topic: Temporary Tablespace
Next Topic: Oracle 10g support in oXygen XML Editor
Goto Forum:
  


Current Time: Fri Nov 22 04:49:54 CST 2024