# Servoy mysql issue

**URL:** <https://forum.servoy.com/t/servoy-mysql-issue/11338>\
**Category:** Classic Servoy\
**Created:** [October 29, 2009, 8:54pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338 "2009-10-29T20:54:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdcunha](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jdcunha](https://forum.servoy.com/u/jdcunha)\
**Post date:** [October 29, 2009, 8:54pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/1 "2009-10-29T20:54:27Z")

</div>

Hi all,

Servoy version: 3.5.10  
OS Platform: Windows

We have a report that is generated by mysql data.

When we run it on small sets of data report runs fine. But on large sets of data we got the following error.  
com.servoy.j2db.persistence.RepositoryException: java.util.NoSuchElementException: Timeout waiting for idle object Timeout waiting for idle object

On doing some research [http://forum.servoy.com/viewtopic.php?f=3&t=11743&p=58795](http://forum.servoy.com/viewtopic.php?f=3&t=11743&p=58795) on the forum we managed to resolve it. It was basically due to minimum number of active connection we had the above error.

However we bumped up the maximum connections setting from 10 to 50 and the report completed without any errors. But we noticed the active connections value not dropping lower even when logging out of the solution from our 3.5.10 version of the servoy server. Every time we ran a report, the active connection creeped up until it reached the maximum and then the solution crashed. The real active connection between the servoy server and the mysql server does not reach 50 viewed from the mysql database.

We are not seeing this happen on our 3.5.3 server. We run a report, the active connection goes up, the report finishes, the active connection goes back down. We have two servers at 3.5.10 (development and the new production server) and one server at 3.5.3 (the old production server).

Is there a setting that needs to be enabled?

Regards  
James Dcunha

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [October 29, 2009, 9:19pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/2 "2009-10-29T21:19:35Z")

</div>

Do you have, by any chance, queries involving compound keys in your report? I experienced a similar, though hard to reproduce, behaviour when asking for 2 columns acting as keys with a query.

---

<div class="post-metadata">

**Author:** ![jkipling](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@jkipling](https://forum.servoy.com/u/jkipling)\
**Post date:** [October 30, 2009, 5:53pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/3 "2009-10-30T17:53:15Z")

</div>

Hi Riccardino,

I’m working with James on this problem. None of our tables use compound keys, however as part of this report we are querying a View. The view is constructed from more than one table but only has a single primary key.

Thanks,  
-Jeremy

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [November 2, 2009, 11:44am UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/4 "2009-11-02T11:44:21Z")

</div>

James,

We have found and fixed a connection leak in Servoy.  
The fix is included in Servoy 4.1.4 and Servoy 5 (currently in RC status).

Rob

---

<div class="post-metadata">

**Author:** ![jdcunha](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@jdcunha](https://forum.servoy.com/u/jdcunha)\
**Post date:** [November 2, 2009, 2:04pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/5 "2009-11-02T14:04:27Z")

</div>

Thanks Rob,

We will test it out and get back to you. Appreciate your help on this.

Regards  
James Dcunha

---

<div class="post-metadata">

**Author:** ![rerngrak](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rerngrak](https://forum.servoy.com/u/rerngrak)\
**Post date:** [November 27, 2009, 10:27am UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/6 "2009-11-27T10:27:47Z")

</div>

Hi, I have the same problem here, but on MS SQL Server  
Servoy 3.5.10  
OS: Windows Server 2003

My function have to call \_myJSFoundSet.loadRecords() 2 times  
and when it call loadRecords(‘select pk1, pk2, pk3 from tbl1’), this make active connection goes up and never down.

I removed this the active connection doesn’t up, I changed to load another table with 1 pk, active connection’s not increase.  
and changed to load from table with 2 pk, it’s up.

According to Rob’s post, Is this a bug too?

Regards  
Rerng Rak

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [December 1, 2009, 9:16am UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/7 "2009-12-01T09:16:26Z")

</div>

Rerng,

Yes, that is the same issue.  
These are 2 situations where Servoy needs a temporary table to perform the query:

- a pk select with more than 200 values, instead of doing ‘where pk in (?, ?, …, ?)’, Servoy saves the values in a temp table to join with
- a custom query on pk select with composite pk, you cannot say ‘where (pk1, pk2) in (select x, y from tab)’ so Servoy also needs a temporary table.  
The connection leak was related to the cleanup of the temporary table.

Rob

---

<div class="post-metadata">

**Author:** ![rerngrak](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@rerngrak](https://forum.servoy.com/u/rerngrak)\
**Post date:** [December 2, 2009, 3:49am UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/8 "2009-12-02T03:49:12Z")

</div>

Hi Rob,  
Thank you for your answer. ![:)]( "Smile")

btw, Is there any best practice to avoid this bug?  
I should change my table structure or there’s has another way to load record from table with composite key

---

<div class="post-metadata">

**Author:** ![Riccardino](https://avatars.discourse-cdn.com/v4/letter/r/41988e/32.png) [@Riccardino](https://forum.servoy.com/u/Riccardino)\
**Post date:** [March 9, 2010, 1:58pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/9 "2010-03-09T13:58:02Z")

</div>

We’re still having this issue (that ends up in killing the db connection). The query, used with a DB2 database, is the following:

````auto
"select lineitems_id from lineitems where offer_id IN (select offer_id from offers where dossier_id = ?) and flag != ?"
```.
The problem remains after upgrading to 4.1.4: do you have any suggestion?
````

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [March 9, 2010, 2:07pm UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/10 "2010-03-09T14:07:46Z")

</div>

Hi Ric,

Not an answer to your question but why use a subselect when you can use a join ?  
Joins are in general much faster.

```auto
SELECT lineitems_id FROM lineitems WHERE offer_id IN (SELECT offer_id FROM offers WHERE dossier_id = ?) AND flag != ?

```

Could be rewritten to

```auto
SELECT lineitems_id FROM lineitems a JOIN offers b ON a.offer_id = b.offer_id WHERE b.dossier_id = ? AND a.flag != ?

```

Hope this helps.

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [March 10, 2010, 9:16am UTC](https://forum.servoy.com/t/servoy-mysql-issue/11338/11 "2010-03-10T09:16:25Z")

</div>

> Riccardino:  
> The problem remains after upgrading to 4.1.4: do you have any suggestion?

Riccardino,

The connection leak issue was actually fixed in 4.1.5, not 4.1.4.

Rob
