Disconnected Mode

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
PoSeiDoN31
Posts: 6
Joined: Wed 12 Sep 2007 15:35

Disconnected Mode

Post by PoSeiDoN31 » Wed 12 Sep 2007 17:44

Hi I've been working with MyDac and I've created an application connecting to MySql. I'm working with disconnected mode and pooling, but i was testing some problems and i completely disconnect the TMyConnection component, this means, that i set the properties:
- Connected = false
- Disconnected Mode = false
- Pooling = false.
The problem is that when i open the TMyQuery component, it connects to the database when it was suppose to throw an exception.

I need your help to figure out this problem.

Thanks.
Oh and I'm new in the forum. i think i can help you with some problems too.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Disconnected Mode

Post by eduardosic » Wed 12 Sep 2007 20:24

PoSeiDoN31 wrote:Hi I've been working with MyDac and I've created an application connecting to MySql. I'm working with disconnected mode and pooling, but i was testing some problems and i completely disconnect the TMyConnection component, this means, that i set the properties:
- Connected = false
- Disconnected Mode = false
- Pooling = false.
The problem is that when i open the TMyQuery component, it connects to the database when it was suppose to throw an exception.

I need your help to figure out this problem.

Thanks.
Oh and I'm new in the forum. i think i can help you with some problems too.
inform more details, what exception are raised?

PoSeiDoN31
Posts: 6
Joined: Wed 12 Sep 2007 15:35

Post by PoSeiDoN31 » Wed 12 Sep 2007 20:39

The problem is that it doesn't throw the exception.
Let me explain better, i have a TMyConnection component pointing to a database and a TMyQuery component that calls a Stored Procedure.

I've set all the properties in the TMyConnection component to be disconnected like i explained in the last post. so that means that i shouldn't be able to execute the query. but when i call the open method of the query it automatically connects to the database and i don't think that is what should happen. i also have the property of the TMyQuery component named Create Connection set to False.

i don't understand why it connects and execute the query when everything is disconnected.

I'll appreciate your help

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

See mydac Help

Post by eduardosic » Wed 12 Sep 2007 20:53

PoSeiDoN31 wrote:The problem is that it doesn't throw the exception.
Let me explain better, i have a TMyConnection component pointing to a database and a TMyQuery component that calls a Stored Procedure.

I've set all the properties in the TMyConnection component to be disconnected like i explained in the last post. so that means that i shouldn't be able to execute the query. but when i call the open method of the query it automatically connects to the database and i don't think that is what should happen. i also have the property of the TMyQuery component named Create Connection set to False.

i don't understand why it connects and execute the query when everything is disconnected.

I'll appreciate your help
in MyDAC Help;;

In disconnected mode a connection opens only when it is required. After performing all server calls connection closes automatically until next server call is required. Datasets remain open when connection closes. Disconnected mode may be useful to save server resources and operate in unstable or expensive network. Drawback of using disconnected mode is that each connection establishing requires some time for authorization. If connection is often closed and opened it can slow down application work. We recommend to use pooling to solve this problem. For additional information see TCustomDAConnection.Pooling.

To enable disconnected mode set TCustomDAConnection.Options.DisconnectedMode to True.

In disconnected mode a connection is opened for executing requests to the server (if it was not already opened) and is closed automatically if it is not required any more. If the connection was explicitly opened (Connect method was called or Connected property was explicitly set to True), it does not close until Disconnect method will be called or Connected property will be explicitly set to False.

Disconnected mode features

If you perform a query with FetchAll option set to true, connection closes when all data are fetched if it is not used by someone else. If FetchAll option is set to false, connection does not close until all data blocks are fetched.

If explicit transaction is started, connection does not close until the transaction will be committed or rolled back.

If the query was prepared explicitly, connection does not close until the query will be unprepared or its SQL text will be changed.

PoSeiDoN31
Posts: 6
Joined: Wed 12 Sep 2007 15:35

Post by PoSeiDoN31 » Wed 12 Sep 2007 21:02

i already read that. but the thing is that i have disconnected mode disabled. so that won't help me.

Thanks anyway

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

wait...

Post by eduardosic » Wed 12 Sep 2007 21:08

PoSeiDoN31 wrote:i already read that. but the thing is that i have disconnected mode disabled. so that won't help me.

Thanks anyway
We go to wait a better explanation of Antaeus.

certainly Antaeus goes to help you better.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 13 Sep 2007 06:52

When you try to open/execute a command with TMyQuery, and linked TMyConnection is closed, TMyQuery initiates connection automatically.
This is a designed behaviour. DisconnectedMode, Pooling, and CreateConnection options have no influence on it.

PoSeiDoN31
Posts: 6
Joined: Wed 12 Sep 2007 15:35

Post by PoSeiDoN31 » Thu 13 Sep 2007 12:07

ok, thanks for solving my problem.
:D

Post Reply