Board index » delphi » TADOConnection.Open hangs

TADOConnection.Open hangs

I am experiencing a problem with my application{*word*154} on the
TADOConnection.Open, i.e. it never returns or raises an exception.

My application is a TService that creates a thread every 2 minutes. The
thread creates and TADOConnection, connects to the database, performs some
activities and closes the database,

i.e

procedure MyThread.Execute

begin

FConnection := TADOConnection.Create(nil);
FConnection.Connectionsstring := ....
FConnection.LoginPrompt := false;
try
  FConnection.Open; // <-- here application just "hangs" after some hundred
times
  ConnectionOK := true;
except
  report error
  ConnectionOK := false;
end;

if connectionOK then begin
  .. do the stuff, i.e. create some datasets that performs some activities
end;

FConnection.Close;
FConnection.Free;

end;

The strange thing is that the thread is created every two minutes for two
days and works beautifully, then all of a sudden it hangs in the same place.
The number times after when it happens seems to vary. The thread contains
other database connections as well, all working nicely except one.

The problem database connection is to

Oracle version 8.1

Other relevant info:

Delphi 7 PRO, Windows 2000 server, MDAC 2.7 SP1 (seems to be happening on
MDAC 2.6 SP2 as well), Oracle client 8.1. I am using the Microsoft Provider
for Oracle,

Any suggestions, I would be deeply grateful !

Per Wirdemark

 

Re:TADOConnection.Open hangs


Check that you close all handles to created threads and free every MyThread
object. The problem may be that in application with default stack size (1MB)
there may be no more than 2028 threads (not only in one application but in
whole system, see CreateThread() help in MSDN). Thread remains in the system
unless all handles to it are closed. 2028 threads and 0.5 (new thread/min)
means that your app may run ~67 hours. But system has other threads -
system, programs etc., let's say ~500 threads. So if you hold thread handles
your app will fail in ~2 days.

Look in task manager how many threads your service uses, take a look at
SvcHost.exe, Services.Exe and System processes.

----------------------------------------------------------------
Regards,
Viatcheslav V. Vassiliev
http://www.oledbdirect.com
The fastest way to access MS SQL Server, MS Jet (MS Access)
and Interbase (through OLEDB) databases.

"Per Wirdemark" <per.wirdem...@canaima.se> ???Y/???Y ?????
???Y??: news:3edca407$1@newsgroups.borland.com...

Quote
> I am experiencing a problem with my application{*word*154} on the
> TADOConnection.Open, i.e. it never returns or raises an exception.

> My application is a TService that creates a thread every 2 minutes. The
> thread creates and TADOConnection, connects to the database, performs some
> activities and closes the database,

> i.e

> procedure MyThread.Execute

> begin

> FConnection := TADOConnection.Create(nil);
> FConnection.Connectionsstring := ....
> FConnection.LoginPrompt := false;
> try
>   FConnection.Open; // <-- here application just "hangs" after some
hundred
> times
>   ConnectionOK := true;
> except
>   report error
>   ConnectionOK := false;
> end;

> if connectionOK then begin
>   .. do the stuff, i.e. create some datasets that performs some activities
> end;

> FConnection.Close;
> FConnection.Free;

> end;

> The strange thing is that the thread is created every two minutes for two
> days and works beautifully, then all of a sudden it hangs in the same
place.
> The number times after when it happens seems to vary. The thread contains
> other database connections as well, all working nicely except one.

> The problem database connection is to

> Oracle version 8.1

> Other relevant info:

> Delphi 7 PRO, Windows 2000 server, MDAC 2.7 SP1 (seems to be happening on
> MDAC 2.6 SP2 as well), Oracle client 8.1. I am using the Microsoft
Provider
> for Oracle,

> Any suggestions, I would be deeply grateful !

> Per Wirdemark

Re:TADOConnection.Open hangs


Thanks for the suggestion, I will check the number of threads, but I think I
would get another error type if I ran out of thread resources.

The application actually spawns a number of other threads as well, but
checks that new thread of the same type is running more than one instance,
and it always hangs in the same thread, on the TADOConnection.Open.

Per

"Viatcheslav V. Vassiliev" <supp...@oledbdirect.com> wrote in message
news:3edcac01$1@newsgroups.borland.com...

Quote
> Check that you close all handles to created threads and free every
MyThread
> object. The problem may be that in application with default stack size
(1MB)
> there may be no more than 2028 threads (not only in one application but in
> whole system, see CreateThread() help in MSDN). Thread remains in the
system
> unless all handles to it are closed. 2028 threads and 0.5 (new thread/min)
> means that your app may run ~67 hours. But system has other threads -
> system, programs etc., let's say ~500 threads. So if you hold thread
handles
> your app will fail in ~2 days.

> Look in task manager how many threads your service uses, take a look at
> SvcHost.exe, Services.Exe and System processes.

> ----------------------------------------------------------------
> Regards,
> Viatcheslav V. Vassiliev
> http://www.oledbdirect.com
> The fastest way to access MS SQL Server, MS Jet (MS Access)
> and Interbase (through OLEDB) databases.

> "Per Wirdemark" <per.wirdem...@canaima.se> ???Y/???Y ?????
> ???Y??: news:3edca407$1@newsgroups.borland.com...
> > I am experiencing a problem with my application{*word*154} on the
> > TADOConnection.Open, i.e. it never returns or raises an exception.

> > My application is a TService that creates a thread every 2 minutes. The
> > thread creates and TADOConnection, connects to the database, performs
some
> > activities and closes the database,

> > i.e

> > procedure MyThread.Execute

> > begin

> > FConnection := TADOConnection.Create(nil);
> > FConnection.Connectionsstring := ....
> > FConnection.LoginPrompt := false;
> > try
> >   FConnection.Open; // <-- here application just "hangs" after some
> hundred
> > times
> >   ConnectionOK := true;
> > except
> >   report error
> >   ConnectionOK := false;
> > end;

> > if connectionOK then begin
> >   .. do the stuff, i.e. create some datasets that performs some
activities
> > end;

> > FConnection.Close;
> > FConnection.Free;

> > end;

> > The strange thing is that the thread is created every two minutes for
two
> > days and works beautifully, then all of a sudden it hangs in the same
> place.
> > The number times after when it happens seems to vary. The thread
contains
> > other database connections as well, all working nicely except one.

> > The problem database connection is to

> > Oracle version 8.1

> > Other relevant info:

> > Delphi 7 PRO, Windows 2000 server, MDAC 2.7 SP1 (seems to be happening
on
> > MDAC 2.6 SP2 as well), Oracle client 8.1. I am using the Microsoft
> Provider
> > for Oracle,

> > Any suggestions, I would be deeply grateful !

> > Per Wirdemark

Other Threads