Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

commit action to insert and to update

scania113hSep 2 2010 — edited Sep 3 2010
hello,

i m using adf afces 11g and MS SQL server 2005 as database,

in my form i m using a commit button that run two action for the same click.

action 1 : fill the id text field if it's empty.
action 2 : commit the the information in the database.

this is the code of the binding method of my commit button :

*public String cb1_action3() throws NamingException, SQLException, ClassNotFoundException {*

*if(it1.getValue()==null){*
Connection connection = ConnectionManager.getInstance().getConnection();
Statement statement = connection.createStatement();
ResultSet resultSet=statement.executeQuery("SELECT max(id) FROM spider");
while(resultSet.next())
*{*
it1.setValue(resultSet.getInt(1)+1);

*}*

BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("Commit");
Object result = operationBinding.execute();
*/* if (!operationBinding.getErrors().isEmpty()) {*
return null;
*}*/*
*}*
*else {*
BindingContainer bindings2 = getBindings();
OperationBinding operationBinding2 = bindings2.getOperationBinding("Commit");
Object result = operationBinding2.execute();
*if (!operationBinding2.getErrors().isEmpty()) {*
return null;
*}*
*}*

return null;
*}*

N.B: it1 is the binding variable of my id text field.

every thing is working fine, the id code is generated and the row is commited in the database, but when i try to edit the same record by the form, an error message says that the INDENTITY_INSERT of the table is turned off.
on my database i run this "set IDENTITY_INSERT spider ON" but the problem is still here.

i need your help.

thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2010
Added on Sep 2 2010
1 comment
646 views