Board index » delphi » dbExpress, MySQL, Killing Cloned Connections

dbExpress, MySQL, Killing Cloned Connections


2003-10-09 03:58:21 AM
delphi236
Help...
I'm writing an app in Delphi 7/Kylix 3 and Mysql 3.23 I have noticed that
the program is cloning the connection to the database when a new Statement
is executed, but I have not been able to tell it to close the new Cloned
connection. Is there any quick way to make it do this? I have tried setting
the database object to Connected := False, but it still will not close the
connections. The only time all the connections will go away is when the
program is closed. I originally thought it was because I was leaving some
Datasets Active, so I made sure I Inactivated all of them and call
CloseDataSet on the Connection. Now it appears that it creates A new
Connection when I use ExecuteDirect off the connection object.
I read that it will automatically clone the connection if it reaches the
MaxStmtsPerConnection limit from the SQL Server, I have not been able to find
anything in MySQL that is similar to this. I am guessing that is probably my
problem. but I don't know where to look, I have look at the Variables that are
set and there isn't one that looks to be the one I would need to change... Any
Suggestions?
Thanks In Advance,
Nick
 
 

Re:dbExpress, MySQL, Killing Cloned Connections

Get the driver from crlab.com and your problems will go away. Borland took
2 years to get out an updated driver that probably still does not work and
has no source with it. You get source with the one from crlab.
"Nick" <XXXX@XXXXX.COM>writes
Quote
Help...

I'm writing an app in Delphi 7/Kylix 3 and Mysql 3.23 I have noticed
that
the program is cloning the connection to the database when a new Statement
is executed, but I have not been able to tell it to close the new Cloned
connection. Is there any quick way to make it do this? I have tried
setting
the database object to Connected := False, but it still will not close the
connections. The only time all the connections will go away is when the
program is closed. I originally thought it was because I was leaving some
Datasets Active, so I made sure I Inactivated all of them and call
CloseDataSet on the Connection. Now it appears that it creates A new
Connection when I use ExecuteDirect off the connection object.
I read that it will automatically clone the connection if it reaches
the
MaxStmtsPerConnection limit from the SQL Server, I have not been able to
find
anything in MySQL that is similar to this. I am guessing that is probably my
problem. but I don't know where to look, I have look at the Variables that
are
set and there isn't one that looks to be the one I would need to change... Any
Suggestions?

Thanks In Advance,
Nick


 

Re:dbExpress, MySQL, Killing Cloned Connections

What I don't understand is that I originally wrote this program in Kylix 1
Server Developer using dbExpress, using the same driver, and I believe the
same code, and this problem never existed in Kylix 1. I just tested that, I
opened the program, ran 6 - 12 queries and I never saw a process for my
machine using the old Kylix 1 App, but with the Kylix 3 App it makes
connections that won't go away. I am using version 10 of the mysql dbexpress
driver. I can not believe there is no way to make the "borland" driver work,
without having to purchase a 3rd party driver.
"Nick" <XXXX@XXXXX.COM>writes
Quote
Help...

I'm writing an app in Delphi 7/Kylix 3 and Mysql 3.23 I have noticed
that
the program is cloning the connection to the database when a new Statement
is executed, but I have not been able to tell it to close the new Cloned
connection. Is there any quick way to make it do this? I have tried
setting
the database object to Connected := False, but it still will not close the
connections. The only time all the connections will go away is when the
program is closed. I originally thought it was because I was leaving some
Datasets Active, so I made sure I Inactivated all of them and call
CloseDataSet on the Connection. Now it appears that it creates A new
Connection when I use ExecuteDirect off the connection object.
I read that it will automatically clone the connection if it reaches
the
MaxStmtsPerConnection limit from the SQL Server, I have not been able to
find
anything in MySQL that is similar to this. I am guessing that is probably my
problem. but I don't know where to look, I have look at the Variables that
are
set and there isn't one that looks to be the one I would need to change... Any
Suggestions?

Thanks In Advance,
Nick


 

Re:dbExpress, MySQL, Killing Cloned Connections

Quote
>connection. Is there any quick way to make it do this? I have tried setting
>the database object to Connected := False, but it still will not close the
>connections. The only time all the connections will go away is when the
>program is closed.
if you set SQLConnection.connected to false, they will all go away.
hth,
pal
 

Re:dbExpress, MySQL, Killing Cloned Connections

As I stated That doesn't work.
paladin writes:
Quote
>>connection. Is there any quick way to make it do this? I have tried setting
>>the database object to Connected := False, but it still will not close the
>>connections. The only time all the connections will go away is when the
>>program is closed.


if you set SQLConnection.connected to false, they will all go away.

hth,
pal


 

Re:dbExpress, MySQL, Killing Cloned Connections

Quote
>>The only time all the connections will go away is when the program is closed.
>if you set SQLConnection.connected to false, they will all go away.
As I stated That doesn't work.
nick,
sorry. I read your post too quickly - thought you meant CDS or SQLSDS or whatever.
the best way to avoid having a bunch of cloned connections{*word*154} around is to
never let the first one happen.
For any DataSet based ops, equip all your providers with AfterGetRecords and
BeforeApplyUpdates event handlers that have an SQLConnection close statement.
(thanks to Dave Rowntree for this)
For execute and executedirect based ops, use this:
if SQLConnection.ActiveStatements>0 then begin
SQLConnection.Close;
SQLConnection.Open;
end;
(thanks to Ramesh for this)
I'd also check this in front of +any+ SQLConnection ops, e.g. GetTableNames
(thanks to Henk Verouden for this)
My experience (not exhaustive, sadly) was that execute left far less connections
hanging around open than did executedirect. Although execute was slower.
See this thread for what I do recall: tinyurl.com/qltk
hth!
regards,
-paladin