Results 1 to 18 of 18
Thread: Timeout db2
- 01-18-2012, 07:27 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Timeout db2
Hi,
I've to insert some data into a DB2 table.
Number of rows is very high, and I need to have a multiple insertion (running more than one instance of the same program).
What I do is essentially the following:
When I run my programs SOMETIMES I get a TIMEOUT ERROR. In particular:Java Code:_cnn.setAutoCommit(false); for(int i=0; i< numRows; i++){ _stm.executeUpdate(row[i]); } _cnn.commit();
SQLCODE = -913
SQLERRD = 00C9008E ---> timeout
(It's not a Deadlock...because deadlock SQLERRD should be 00C90088).
So, the solution is to increase timeout. By I wasn't able to do it.
I tryed inserting "locktimeout" when estabilishing connection:
Il connects, but DB2 timeout seems do not change...Java Code:Properties prop = new Properties(); prop.setProperty("locktimeout", "900"); ... _cnn = DriverManager.getConnection(_Url, prop);
So I tryed modifing currentlocktimeout in this way:
but no effect again...Java Code:DB2DataSource ds = new DB2DataSource(); .... ds.setCurrentLockTimeout(900); ... _cnn = ds.getConnection(_User, _Pswd);
Is there a way to change timeout in a DB2 TABLE????
- 01-19-2012, 06:02 AM #2
Re: Timeout db2
You probably have to change the timeout values server side!
- 01-19-2012, 08:37 AM #3
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: Timeout db2
Can I do it by a Java Program???
How can I do it...?
- 01-19-2012, 10:37 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Re: Timeout db2
Could you batch the commands and fire a single execute?
You're doing a (potentially) awful lot of toing and froing with the database there by doing single execute calls.
- 01-19-2012, 11:16 AM #5
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: Timeout db2
I've a TREEMAP, in which I put all rows to insert in DB.
When I complete TREEMAP I execute every single query white a for.
I tryed to use addBatch() and ad the end executeBatch() but after about 20 minutes...It returns an error...
I tryed to autocommit every insert...and in this case NO PROBLEM!
So It's sure a timeout problem. In particular I can see that timeout start after 3 minutes!
Some suggestion??
- 01-19-2012, 12:10 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Re: Timeout db2
It errors?
What error does it give on a batch update then, out of curiosity?
- 01-19-2012, 02:20 PM #7
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
- 01-19-2012, 02:46 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Re: Timeout db2
Ah.
I've never had to deal with DB2, so it's quite possible this is something to do with the database itself?
- 01-19-2012, 03:10 PM #9
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
- 01-19-2012, 04:15 PM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Re: Timeout db2
Looking up that error it's not a connection timeout but a wait timeout.
That is, the query/update/insert is waiting on another query/update/insert to commit and/or complete.
Now, since you say you are doing this using multiple instances then that is no surprise.
DB2 is likely to lock the table you are inserting to for example, or lock the row you are updating, either of which can result in another instance of your program being forced to hang around since the first instance is not going to commit til it's finished.
This is why, when you commit after each insert/etc it works.
- 01-19-2012, 06:27 PM #11
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: Timeout db2
First of all...thanks for your answer.
So, DB2 locks table while inserting/updating rows and release lock when commit is made.
Is there a way to make multiple insert? I can se from ibm specifics that exists 2 db2 parameters, "maxlocks" and "locklist" that can be useful to resolve my problem...
But I haven't find a way to set that in my java program...
- 01-19-2012, 06:33 PM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Re: Timeout db2
Can't guarantee exactly how it locks, but it's pretty clear you are getting a clash.
The only thing I can suggest is to not parallelise (is that a word?) the bulk changes into a particular table.
- 01-19-2012, 06:41 PM #13
Member
- Join Date
- Jan 2012
- Location
- Panamá
- Posts
- 41
- Rep Power
- 0
Re: Timeout db2
I agree with Tolls, is better to use batch for that case.
You can check the code that suggests ibm:
DB2 Universal Database
To see the timeout error, if you have access to as400 WRKACTJOB can use the command and look for the state that corresponds to your user or workstation.
- 01-19-2012, 07:16 PM #14
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
Re: Timeout db2
I've tryed that code, but nothing. How I said some post ago, after 20 minutes executeBatch throws an exception and returns me SQLCODE -913 (timeout).
How can I se if I have access to as400 WRKACTJOB?
It's sad I can't "parallelise" insertion...!
I'm considering to commit at every insert...
But know there's another problem:
Sometimes program crash for unknown reason...
If some rows was inserted before crashing...It will give me error when restarting execution (It will start inserting from the first row again).
I tried to use istruction like "replace" (in sql it's like insert, but in presence of duplicate, it delete first the row and then insert) or "insert ignore" (only a warning if row is present)...but maybe they aren't legal istruction in DB2..!
desperation
- 01-19-2012, 08:25 PM #15
Member
- Join Date
- Jan 2012
- Location
- Panamá
- Posts
- 41
- Rep Power
- 0
Re: Timeout db2
SQLCODE -913 (timeout).
1 - IBM Information Management Software for z/OS Solutions Information Center
2 - IBM Information Management Software for z/OS Solutions Information Center
-913
UNSUCCESSFUL EXECUTION CAUSED BY DEADLOCK OR TIMEOUT. REASON CODE reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name
- 01-19-2012, 08:37 PM #16
Member
- Join Date
- Dec 2011
- Posts
- 10
- Rep Power
- 0
- 01-19-2012, 08:42 PM #17
Member
- Join Date
- Jan 2012
- Location
- Panamá
- Posts
- 41
- Rep Power
- 0
Re: Timeout db2
In the as400 you will notice that the process is on hold with the command wkractjob
- 01-20-2012, 09:53 AM #18
Moderator
- Join Date
- Apr 2009
- Posts
- 10,468
- Rep Power
- 16
Similar Threads
-
JAR server timeout
By Axephilic in forum Advanced JavaReplies: 0Last Post: 10-24-2011, 07:22 PM -
getHostName(). is there any way to set timeout??
By nikmanutd in forum NetworkingReplies: 1Last Post: 10-05-2011, 06:09 PM -
Implement a timeout
By pjmorce in forum Advanced JavaReplies: 5Last Post: 04-27-2010, 02:36 AM -
Java RMI timeout
By sky in forum Advanced JavaReplies: 0Last Post: 03-17-2010, 12:44 AM -
Socket Timeout?
By Moncleared in forum New To JavaReplies: 1Last Post: 09-12-2009, 04:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks