Fórum Como verifico se o banco de dados (Oracle) está acessível #196367
21/11/2003
0
Antes de conectar no banco de dados Oracle (evento: BeforeConnect do objeto TDataBase), quero verificar se este está no ar / startup.
Qualquer ajuda é bem-vinda,
Fabiana Linden (GO)
Falinden
Curtir tópico
+ 0Posts
21/11/2003
Falinden
Grata,
Fabiana
Gostei + 0
05/03/2004
Motta
procedure TForm1.SpeedButton2Click(Sender: TObject);
var DriverParams : TStringList;
begin
{A solução está aqui abro com a 32
se deu erro
trato
senao
fecho e abro com a 8}
{http://www.delphi32.com/info_facts/faq/faq_970.asp
When connecting to Oracle 7, DLL32 in BDE Administrator is normally set to
SQLORA32.DLL.
When connecting to Oracle using SQLORA32.DLL the connection is made via calling
the Oracle OCI function ologon.
When connecting to Oracle 8, DLL32 in BDE Administrator is normally set to SQLORA8.DLL.
When connecting to Oracle using SQLORA8.DLL the connection is made via calling the
Oracle OCI function OciBegin Session.
The reason SQLORA8.DLL and SQLORA32.DLL raise different errors is because ologon
and OciBeginSession generate different errors when an incorrect login is attempted.
If you connecting to an Oracle 8 database, but like the errors that SQLORA32.DLL
generates, here is a way to get the most out of SQLORA8.DLL and SQLORA32.DLL. }
with DataBase1 do
begin
Shape1.Brush.Color := clRed;
try
Close;
LoginPrompt:= False;
Params.Values[´USER NAME´]:= Edit2.Text;
Params.Values[´PASSWORD´] := Edit3.Text;
DriverParams := TStringList.Create;
try
DriverParams.Add(´DLL32=SQLORA32.DLL´);
Session.ModifyDriver(´Oracle´,DriverParams);
Database1.Open;
//if no exception is raised, then close database and reopen with SQLORA8.DLL
Database1.Close;
DriverParams.Clear;
DriverParams.Add(´DLL32=SQLORA8.DLL´);
Session.ModifyDriver(´Oracle´,DriverParams);
Database1.Open;
finally
DriverParams.Free;
end;
Shape1.Brush.Color := clGreen;
except
on e:exception do
begin
{Trocar por msg civilizadas}
if (Pos(´PASSWORD´,UpperCase(e.message)) > 0) then
ShowMessage(´Sua besta, vc errou a sua conta ou a senha !!!´)
else
if (Pos(´EXCLUSIVE´,UpperCase(e.message)) > 0) or
(Pos(´ORACLE NOT AVAILABLE´,UpperCase(e.message)) > 0) or
(Pos(´SHUTDOWN IN PROGRESS´,UpperCase(e.message)) > 0) or
(Pos(´ORACLE ONLY AVAILABLE TO´,UpperCase(e.message)) > 0) then
ShowMessage(´O Banco está fora para a ralé !!!´)
else
if (Pos(´20171´,UpperCase(e.message)) > 0) then
ShowMessage(´Como vc pode estar em dois lugares ao mesmo tempo ???´)
else
if (Pos(´LOGGED ON´,UpperCase(e.message)) > 0) then
ShowMessage(´Não estamos a fim de dizer o maldito erro !!!´)
else
if (Pos(´HOSTDEF EXTENSION DOES NOT EXIST´,UpperCase(e.message)) > 0) then
ShowMessage(´O BDE desta máquina tem pobrema !!!´)
else
if (Pos(´INSUFFICIENT PRIVILEGES´,UpperCase(e.message)) > 0) then
ShowMessage(´Nem direito de conectar você tem !!!´)
else
ShowMessage(e.Message);
end;
end;
end;
end;
Gostei + 0
05/03/2004
Falinden
agradeço o empenho em me ajudar, vou testar o código acima.
Valeu !
A propósito, dei umas boas rizadas com os seus showmessages :wink:
Grata,
Fabiana Linden
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)