IMHO there should be no deadlock possible after all writes have been committed.
Even before, as your batch does inserts and not updates I don't think you should have a deadlock, but this might depend on database and used isolation.
Anyway - after a commit everything should be fine. If you say it is not, what happens if you close the connection you created?
Announcement
Collapse
No announcement yet.
X
-
What if the JDBC and the DSRequest use different connections? As they do, since the connection for the JDCB Request is created by
con = DriverManager.getConnection(sqlConnectionString);
Leave a comment:
-
Hm, if this is true, why am I getting a deadlock on the db? The table I am inserting to is locked and the DSRequest is waiting for the lock ...
Leave a comment:
-
I am asking if it does that ;-) I always worked directly with DSRequests, so I am not sure if JDBC executes() are also synchronous
Leave a comment:
-
Hi edulid,
I'd expect it to do that. Are you saying that it does not?
Best regards
Blama
Leave a comment:
-
Ok, but executing batchStmt with batchStmt.executeBatch() should be synchronous or ?
If I write:
would this execute in order and would the DSResponse see the inserts inserted by the batchStmt?Code:batchStmt.executeBatch(); conn.commit(); DSResponse yourResp = yourFetch.execute();
Leave a comment:
-
Hi Edulid,
isn't all SmartGWT server side request processing synchronous?
should execute in order. Problem is when the batchStmt uses a transaction and the yourFetch does not use the same transaction. Then the transaction of batchStmt must be committed before you start your fetch.Code:batchStmt.executeBatch(); DSResponse yourResp = yourFetch.execute();
Best regards
Blama
Leave a comment:
-
The example (http://www.smartclient.com/smartgwte...jdbcOperations) seems to be what I need, since I am not running a standalone process and I am able to run normal DSRequests.
What I am asking is how to combine JDBC Inserts and a DSRequest after the inserts, and make sure the JDBC Inserts are finished before executing the DSRequest.
So I have JDBC Inserts:
And then:Code:PreparedStatement batchStmt = con.prepareStatement(insertSql); .... batchStmt.executeBatch();
Since the DSRequest is a fetch, and I am using the data inserted by the JDBC inserts, I need to know that the Inserts are finished before doing the DSRequest.Code:DSRequest request = new DSRequest("ds", "fetch");
I looked at your example and I see:
But, since my DSRequest is a server-side created request, created after I execute the JDBC Inserts, and not part of a transaction, I always get con = null.Code:Connection conn = (Connection)((BasicDataSource)req.getDataSource()).getTransactionObject(req);
Normally, for my JDBC Inserts, I get the connection this way:
Another question: maybe I don't need transactions for this purpose?Code:con = DriverManager.getConnection(sqlConnectionString);
After my java code returns from the call to
are the Insert statements already in the DB? If this is true, I could directly call my DSRequest, since the Inserts are already in the DB. Do you know if this is the case?Code:batchStmt.executeBatch();
Leave a comment:
-
We're not sure what you mean when you say you "don't have any RPCManager"..
If you mean you are running a command line process, see the Standalone DataSource Usage overview.
If you mean you just don't understand how to have an RPCManager in this instance, see this sample showing how to use the JDBC API while still participating in an RPCManager-managed transaction.
Leave a comment:
-
DSRequest after PreparedStatement
I have a PreparedStatement for doing a batch insert, which I execute using
This batchStmt executes a lot of INSERTs, that's why I am using it directly and not DSRequests.Code:batchStmt.executeBatch();
AFTER this batch insert I need to call a DSRequest in order to update the inserted values. I must be sure that the batch insert is completely finished before doing the DSRequest. How to achieve this? With smartGWT I would set the same RPCManager for both DSRequests, but here I don't have any RPCManager, since the first request is a PreparedStatement. So how to achieve this?
Using smartgwt 5.1p 31.03 powerTags: None
Leave a comment: