I have created a simple program without any user interface to test connection to Oracle Database. Connecting to database using ODAC net works fine both in Windows XP and Fedora 4. That is, I have set the TOraSession.Options.Net to true and used the connect string as ‘scott/[email protected]:1521:orcl’.
But I wanted to use OCI connect string as ‘scott/tiger@orcl’. Hence we set the TOraSession.Options.Net to false and used the connect string as ‘scott/tiger@orcl’. We added TNS_ADMIN variable in Windows and LINUX to point to oracle_home/network/admin and in that location exists a file tnsnames.ora which contains necessary information about orcl. Our program works under windows. But in Fedora it gives the following error:
Exception EAccessViolation in module OracleTestConsole at 080588AD.
Access violation at address 01A387BE, accessing address 00000000.
I have set the following environment variables:
ORACLE_HOME
TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/network/lib
I tested sqlplus using scott/tiger@orcl and it works fine and we are able to connect to the database.
The following is my source code:
program OracleTestConsole;
{$APPTYPE CONSOLE}
uses
Ora, SysUtils;
var
Query : TOraQuery;
Session : TOraSession;
begin
Writeln('Creating Session...');
Session := TOraSession.Create(nil);
Query := TOraQuery.Create(nil);
Session.AutoCommit := True;
Session.ConnectPrompt := False;
Session.LoginPrompt := False;
Session.Options.Net := False;
Session.ConnectString := 'scott/tiger@orcl';
WriteLn('Connecting...');
Session.Connect;
if (Session.Connected ) then
WriteLn('Session successfully connected');
Query.Session := Session;
Query.SQL.Text := 'select * from emp';
Writeln('Executing query...');
Query.Open;
while not Query.Eof
do
begin
Writeln(Query.Fields[1].AsString);
Query.next;
end;
{while}
Writeln('Closing Query & Session');
Query.Close;
Session.Disconnect;
end.
Could it be that I missed any environment setting?
Thanks,
Jeremy