Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: IBConfigService ShutdownDatabase


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Mar 4, 2015 4:17 AM Last Post By: Mike Norayr Mon...
Mike Norayr Mon...

Posts: 49
Registered: 11/18/99
IBConfigService ShutdownDatabase  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2015 10:56 AM
I use Delphi XE7 update 1 and Interbase XE3, Update 4 hotfix 3. The IBX version is 17.17. I have the following code to shutdown an interbase database:

IBConfigService1.DatabaseName:= 'TEST.gdb';
IBConfigService1.Active:= True;
IBConfigService1.ShutdownDatabase(Forced, 0);

When the last line is executed, I get an "EIBInterbaseError" exception: "Error writing data to connection".

Am I missing something? What do I need to do to make it work? I tried different things to no avail. e.g. increasing the wait seconds, using "application.processmessages" after the shutodowndatabase.

I have to mention that even though I'm getting the exception, the ShutdownDatabase IS disconnecting all current connections.
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBConfigService ShutdownDatabase  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2015 2:01 PM   in response to: Mike Norayr Mon... in response to: Mike Norayr Mon...
Mike Norayr Monjian wrote:
I use Delphi XE7 update 1 and Interbase XE3, Update 4 hotfix 3. The IBX version is 17.17. I have the following code to shutdown an interbase database:

IBConfigService1.DatabaseName:= 'TEST.gdb';
IBConfigService1.Active:= True;
IBConfigService1.ShutdownDatabase(Forced, 0);

When the last line is executed, I get an "EIBInterbaseError" exception: "Error writing data to connection".

Am I missing something? What do I need to do to make it work? I tried different things to no avail. e.g. increasing the wait seconds, using "application.processmessages" after the shutodowndatabase.

I have to mention that even though I'm getting the exception, the ShutdownDatabase IS disconnecting all current connections.

DatabaseName should be the full path to the DB. Also if you have active
TIBDatabases you might want to shut them down first.

Here is the IBX unit test for ShutdownDatabase

Setup of component
   svcConfig.Params.Values['user_name'] := 'sysdba';
   svcConfig.Params.Values['password'] := 'masterkey';
   svcConfig.LoginPrompt := False;
   svcConfig.DatabaseName := PATH_TO_GDB + dmDataConvU.DBFileName;
   svcConfig.ServerName := WHERE_SERVER;
   svcConfig.Active := true;


use of component (options is one of the TShutdownMode options.
     IBDatabase1.Close;
     Sleep(10);
     try
       case Options of
         Forced:
           svcConfig.ShutdownDatabase(Options, Wait);
         DenyTransaction:
           svcConfig.ShutdownDatabase(Options, Wait);
         DenyAttachment:
           svcConfig.ShutdownDatabase(Options, Wait);
       end;
     except
       on E : EIBError do
          Comparer.LogFailure('Failed at shutdown Options ' + 
GetEnumName(TypeInfo(TShutdownMode),
                   integer(Options)) + ' Error Message ' + E.Message +
                   ' ErrorCode ' + IntToStr(E.IBErrorCode));
     end;


The sleep(10) is there due to under VM's sometimes you will get a Service not
attached if you fire off things too fast, so gives the system just a little rest
between the disconnect and the actual shutdown. I suspect it was there for the
error message you are getting but that was written like a decade ago.

Yes the case makes no sense. It was probably refactored at some point and I
didn't bother cleaning that up to the single line it could be reduced to.

Also note that while it kicks everyone out, Sysdba can always get back in so if
you let people come in as sysdba you have only temporarily stopped people from
getting in.

--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Jeff Overcash (...

Posts: 1,529
Registered: 9/23/99
Re: IBConfigService ShutdownDatabase  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2015 2:02 PM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
I forgot the calling code looks like

procedure IBconfigService.TestShutdownDatabase;
var
   Wait: Integer;
   Options: TShutdownMode;
begin
   options := IBX.IBServices.Forced;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   options := IBX.IBServices.DenyTransaction;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   options := IBX.IBServices.DenyAttachment;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   HasErrors;
end;


--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Mike Norayr Mon...

Posts: 49
Registered: 11/18/99
Re: IBConfigService ShutdownDatabase  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 4, 2015 4:17 AM   in response to: Jeff Overcash (... in response to: Jeff Overcash (...
Jeff Overcash (TeamB) wrote:
I forgot the calling code looks like

procedure IBconfigService.TestShutdownDatabase;
var
   Wait: Integer;
   Options: TShutdownMode;
begin
   options := IBX.IBServices.Forced;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   options := IBX.IBServices.DenyTransaction;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   options := IBX.IBServices.DenyAttachment;
   Wait := 0;
   FdmServices.ShutdownDatabase(Options, Wait);
 
   HasErrors;
end;


--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)

Hi Jeff

I followed your steps and everything works fine. Just FYI, maybe it will help others too, I had followed all the steps you sent me above but with the following 2 differences:

1.) I was setting up the IBConfigService1 before closing the database.
2.) I was using IBConfigService.Databasename:= "localhost:c:\TEST.gdb", and was leaving the IBConfigService.ServerName blank.

I had to change them both to match with your steps for it to work. Changing just 1 didn't fix the problem.

One more thing, I added the following code after the ShutdownDatabase before performing any tasks on the database:
Sleep(2000).

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02