Java 在oracle中释放锁时,在会话bean中选择更新查询
下面是会话bean中的方法Java 在oracle中释放锁时,在会话bean中选择更新查询,java,oracle,ejb,Java,Oracle,Ejb,下面是会话bean中的方法 public pin() {// session bean method with @@ejb.transaction type="Requires" update() } private update(){ query = select id from test for update where id = 'ttt' for update; execute(strSelectQuery); } public ResultObject execut
public pin() {// session bean method with @@ejb.transaction type="Requires"
update()
}
private update(){
query = select id from test for update where id = 'ttt' for update;
execute(strSelectQuery);
}
public ResultObject execute(String statement) {
ResultObject ro = new ResultObject(0,null);
if( ds == null ){
try {
InitialContext ctx = new javax.naming.InitialContext();
ds = (javax.sql.DataSource) ctx.lookup(getDataSourceName());
debugLog( "Got ds" );
} catch(NamingException e) {
ro.setResponseCode(-1);
e.printStackTrace();
}
}
OracleCachedRowSet rowSet = null;
if( !ro.isError()){
Connection con = null;
PreparedStatement pstmt = null;
try{
con = ds.getConnection();
pstmt = con.prepareStatement(statement);
rowSet = new OracleCachedRowSet();
debugLog("Query :"+ statement);
rowSet.populate(pstmt.executeQuery());
rowSet.beforeFirst();
ro.setResponseObject(rowSet);
}catch(SQLException e) {
errorLog("SqException "+e);
ro.setResponseCode(-1);
ro.setResponseObject("Error while firing query");
e.printStackTrace();
}finally{
try{
if(pstmt != null) pstmt.close();
if(con != null) con.close();
}catch(Exception e1){
errorLog("Exception "+e1);
ro.setResponseCode(-1);
ro.setResponseObject("Error while firing query");
e1.printStackTrace();
}
}
}
return ro;
}
我的问题是,当从字段释放锁时,我是否使用select进行更新查询
1) When execute method exit ? (as it close connection open for select query).
or
2) When pin method exit as pin is session bean method.
事务边界是顶级的ejb方法(SO2)