java代码锁数据行,java如何给数据库加行锁(事务处理)

Java code01498 //--------------------------------

01499 // addBatch()

01500 // adds a set Of Parameters for executeBatch Updates.

01501 //--------------------------------

01502

01503 public void addBatch() throws SQLException

01504 {

01505 if (OdbcApi.getTracer().isTracing ()){

01506 OdbcApi.getTracer().trace ("*PreparedStatement.addBatch");

01507 }

01508

01509 try

01510 {

01511 int storedSize;

01512

01513 //get from storage Vector and add values to it.

01514 batchSqlVec = myConnection.getBatchVector(this);

01515

01516 // If adding parameter for the first time

01517 // create the vector to hold them.

01518 if ( batchSqlVec == null )

01519 {

01520 batchSqlVec = new Vector(5,10);

01521

01522 storedSize = 0;

01523 }

01524 else

01525 {

01526 storedSize = batchSqlVec.size();

01527 }

01528

01529 Object[] addBatchParams = arrayParams.getStoredParameterSet();

01530 int[] addBatchParamsIdx = arrayParams.getStoredIndexSet();

01531

01532 int batchDataLen = addBatchParams.length;

01533 int batchIdxLen = addBatchParamsIdx.length;

01534

01535 if ( batchIdxLen == numParams )

01536 {

01537 batchSqlVec.addElement(addBatchParams);

01538

01539 myConnection.setBatchVector(batchSqlVec, this);

01540

01541 arrayParams.storeRowIndex( storedSize, addBatchParamsIdx );

01542

01543 batchOn = true;

01544 }

01545 else if ( storedSize == 0 )

01546 {

01547 throw new SQLException("Parameter-Set has missing values.");

01548 }

01549 else

01550 {

01551 //myConnection.setBatchVector(batchSqlVec, this);

01552 batchOn = true;

01553 }

01554

01555 }

01556 catch (NullPointerException e)

01557 {

01558 //throw new SQLException("Parameter Set has missing values");

01559 batchOn = false;

01560 }

01561

01562 }

01563

------解决方案--------------------

没用过这个数据库。。alter table table_name lock mode row这样么

http://www.cntxk.com/catanews/56/info8355.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值