you can try this:
SELECT * FROM table_name FOR UPDATE;
SELECT * FROM table_name FOR UPDATE;
解决方案 »
- java连接jdbc数据库查询的时候出现个问题.
- java中Wrapper接口的作用,有经验的谈谈
- list 遍历问题
- 向高手请教,使用acrobat javascript打印PDF时的一个问题....
- 如何读java源代码
- 工作职位 请教大家?
- 连接池 也不行吗??
- 高手请进,请问com.inet.tds.TdsDataSource这个包在哪里下或?
- === 分页显示的问题 ===
- welcomeAction.do的.do是什么意思?
- what's problem with a one to one relationship between two beans?
- 非高手莫进,我用JAVA+AXIS做了一个WEBSERVICE,用。NET应用程序访问成功,为什么用微软的htc控件访问返回就空值?
^_^
specifies that dirty reads, nonrepeatable reads,
and phantom reads are prevented.This is the compatible way.
and my jdbc invoke by ejb, its join ejb's transaction, I think it couldn't set transaction level for self connection.Add "for update" at the end of that sql can lock that record? if lock how to open that lock? if update fail in later, will it rollback and auto open this lock?
<isolation-level>TransactionSerializable</isolation-level>
<method>
<description>...</description>
<ejb-name>...</ejb-name>
<method-intf>...</method-intf>
<method-name>...</method-name>
<method-params>...</method-params>
</method>
</transaction-isolation>Deployment file: weblogic-ejb-jar.xml
If I use TransactionSerializable, it will some error occured.
I have not investigate this problem.
try this, you send some vendor specific sql query to DB and lock the tables, then do what ever you want, then unlock them,MySQL:
String sql = "xxxxxxxxxxxxxxx";
stat.execute("lock tables tableName WRITE"); //shold check the result
rs = stat.executeQuery(sql);
while(rs.next()) {
String sql_in = "update tableName set value=xxx";
another_stat.execute(sql_in);
}
stat.execute("unlock tables");
I just want to lock the records that I selected.Because between I select this record and modify its value on page and update this, other user couldn't modify same record.