Re: Row Level Locking via JDBC
Posted in 2004
--0__=88BBE40BDFC8223E8f9e8a93df938690918c88BBE40BDFC8223E
Content-type: multipart/alternative;
Boundary="1__=88BBE40BDFC8223E8f9e8a93df938690918c88BBE40BDFC8223E"
--1__=88BBE40BDFC8223E8f9e8a93df938690918c88BBE40BDFC8223E
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: quoted-printable
U can probably do something as follows:
CREATE TABLE Dummy (
ID integer NOT NULL=
,
Counter integer
) LOCK MODE ROW;
CREATE INDEX i1_Dummy on Dummy(ID); <=3D=3D Add
{
st =3D conn1.createStatement();
st.executeUpdate("set lock mode to wait 60"); <=3D=3D=3D Add
st.executeUpdate("insert into dummy values (1, 1)");
st =3D conn2.createStatement();
st.executeUpdate("set lock mode to wait 60"); <=3D=3D Add
st.executeUpdate("insert into dummy values (2, 2)");
conn1.commit();
conn2.commit();
st =3D conn1.createStatement();
st.executeUpdate("update dummy set counter =3D 3 where id =3D 1");
conn1.commit(); <=3D=3D Change
st =3D conn2.createStatement();
st.executeUpdate("update dummy set counter =3D 3 where id =3D 2");
conn2.commit();
}
HTH
Thanx much,
Rajib Sarkar
Advisory Software Engineer
DB2/UDB Regional Advanced Support
IBM Data Management Group
Ph : (602)-217-2100
Fax: (602)-217-2100
T/L : 667-2100
http://www.ibm.com/software/data/db2/udb/winos2unix/support
If we all did the things we are capable of doing, we would literally
astound ourselves. -- T. Edison
=
soeren.ehm@evodio =
n.de (S?ren Ehm) =
Sent by: =
To
owner-informix-li informix-list@iiug.org =
st@iiug.org =
cc
=
Subj=
ect
05/18/2004 05:55 Row Level Locking via JDBC =
AM =
=
=
Please respond to =
soeren.ehm =
=
=
Hello,
I have problems to set up Row Level Locking for my DB Connect.
Following Source Code produces the error code:
"Could not do a physical-order read to fetch next row."
Here is the sql statement for the table.
CREATE TABLE Dummy (
ID integer NOT NULL=
,
Counter integer
) LOCK MODE ROW;
And here is the part of the program.
{
st =3D conn1.createStatement();
st.executeUpdate("insert into dummy values (1, 1)");
st =3D conn1.createStatement();
st.executeUpdate("insert into dummy values (2, 2)");
conn1.commit();
conn2.commit();
st =3D conn1.createStatement();
st.executeUpdate("update dummy set counter =3D 3 where id =3D 1");
st =3D conn2.createStatement();
st.executeUpdate("update dummy set counter =3D 3 where id =3D 2");
conn1.commit();
conn2.commit();
}
Maybe you can help me.
Thanks in advance
Soeren Ehm
=
--1__=88BBE40BDFC8223E8f9e8a93df938690918c88BBE40BDFC8223E
Content-type: text/html; charset=US-ASCII
Content-Disposition: inline
Content-transfer-encoding: quoted-printable
<html><body>
<p>U can probably do something as follows:<br>
<br>
<tt>CREATE TABLE Dummy (<br>
ID integer NOT NULL,<br>
Counter integer<br>
) LOCK MODE ROW;<br>
</tt><br>
<tt>CREATE INDEX i1_Dummy on Dummy(ID); <=3D=3D Add</tt><br>
<br>
<tt>{<br>
</tt><br>
<tt> st =3D conn1.createStatement();</tt><br>
<tt> st.executeUpdate("set lock mode to wait 60"); &nbs=
p; <=3D=3D=3D Add<br>
st.executeUpdate("insert into dummy values (1, 1)"); <=
br>
<br>
st =3D conn2.createStatement();</tt><br>
<tt> st.executeUpdate("set lock mode to wait 60"); &nbs=
p;<=3D=3D Add<br>
st.executeUpdate("insert into dummy values (2, 2)");<b=
r>
<br>
conn1.commit();<br>
conn2.commit();<br>
<br>
<br>
st =3D conn1.createStatement();<br>
st.executeUpdate("update dummy set counter =3D 3 where id =3D=
1");</tt><br>
<tt> conn1.commit(); <=3D=3D Change<br>
<br>
st =3D conn2.createStatement();<br>
st.executeUpdate("update dummy set counter =3D 3 where id =3D=
2");<br>
conn2.commit();<br>
} <br>
</tt><br>
HTH<br>
<br>
Thanx much,<br>
<br>
Rajib Sarkar<br>
Advisory Software Engineer<br>
DB2/UDB Regional Advanced Support<br>
IBM Data Management Group<br>
Ph : (602)-217-2100<br>
Fax: (602)-217-2100<br>
T/L : 667-2100<br>
<a href=3D"http://www.ibm.com/software/data/db2/udb/winos2unix/support"=
>http://www.ibm.com/software/data/db2/udb/winos2unix/support</a><br>
<br>
<br>
If we all did the things we are capable of doing, we would literally as=
tound ourselves. -- T. Edison<br>
<br>
<img src=3D"cid:10__=3D88BBE40BDFC8223E8f9e8a93df938@us.ibm.com" width=3D=
"16" height=3D"16" alt=3D"Inactive hide details for soeren.ehm@evodion.=
de (S?ren Ehm)">soeren.ehm@evodion.de (S?ren Ehm)<br>
<br>
<br>
<table width=3D"100%" border=3D"0" cellspacing=3D"0" cellpadding=3D"0">=
<tr valign=3D"top"><td style=3D"background-image:url(cid:20__=3D88BBE40=
BDFC8223E8f9e8a93df938@us.ibm.com); background-repeat: no-repeat; " wid=
th=3D"40%">
<ul>
<ul>
<ul>
<ul><b><font size=3D"2">soeren.ehm@evodion.de (S?ren Ehm)</font></b><fo=
nt size=3D"2"> </font><br>
<font size=3D"2">Sent by: owner-informix-list@iiug.org</font>
<p><font size=3D"2">05/18/2004 05:55 AM</font>
<table border=3D"1">
<tr valign=3D"top"><td width=3D"168" bgcolor=3D"#FFFFFF"><div align=3D"=
center"><font size=3D"2">Please respond to<br>
soeren.ehm</font></div></td></tr>
</table>
</ul>
</ul>@