Connect Zeoslib to Oracle

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Post Reply
User avatar
GhostReaper
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 11.06.2014, 07:47
Location: South Africa

Connect Zeoslib to Oracle

Post by GhostReaper »

Hi

I am very new to Zeoslib and I am trying to connect the ZConnection1 component to my Oracle 11G R2 database using Delphi XE2, but I cannot seem to get it connected.

I already use a set of 3rd party software, Direct Oracle Access and the standard BDE TDatabase component which use my TNS.ora file to connect to the database with ease.

The problem is the newer versions of XE no longer use BDE components and Direct Oracle Access does not provide all the components we need but Zeoslib does, but I am not sure what properties need to be set in order for the component to see the database and connect to it?

Both the 'Database' and 'LibraryLocation' fields are looking for actual files, 'HostName' is blank, and 'Port' is equal to 0.
Last edited by GhostReaper on 03.07.2015, 07:34, edited 1 time in total.
miab3
Zeos Test Team
Zeos Test Team
Posts: 1309
Joined: 11.05.2012, 12:32
Location: Poland

Re: Connect Zeoslib to Oracle

Post by miab3 »

Database
Password
Protocol
User

possibly LibraryLocation

Michal
User avatar
GhostReaper
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 11.06.2014, 07:47
Location: South Africa

Re: Connect Zeoslib to Oracle

Post by GhostReaper »

miab3 wrote:Database
Password
Protocol
User

possibly LibraryLocation

Michal
Okay I don't understand what you mean?

I am used to using the tnsnames.ora file within my oracle setup, so that when I drop a BDE TDatabase component onto a form within Delphi, in the database parameter, it picks up automatically all my database connections. Are you saying that I need to physically select my tnsnames.ora file in the Database parameter of the ZConnection component as it is looking for a specific file? The name of the database and port number is in the tnsnames.ora file, so do I still need to specify the Port number then?

I also need to be able to connect to a remote MySQL server to access its data and send and receive data from the local Oracle server to the remote MySQL, but at the moment we use TDatabase component and a standard ODBC 5.3 Driver to connect to the remote server, so there is no local libmysql*.dll files, how do I get the ZConnection to connect to the remote SQL database?
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Re: Connect Zeoslib to Oracle

Post by Pitfiend »

Here's an example of what I do to connect to any database engine supported by ZeosLib

Code: Select all

     fini:= TIniFile.Create(ChangeFileExt( application.ExeName,'.ini')) ;
     with ZConnection1 do begin
          Protocol := fini.ReadString('Database', 'Protocol', 'mysqld-5');
          Database := fini.ReadString('Database', 'Database', 'historial');
          if Protocol='mysqld-5' then begin
             Properties.Add('ServerArgument1=--basedir=./');
             Properties.Add('ServerArgument2=--datadir=./data');
             Properties.Add('ServerArgument3=--character-sets-dir=./share/charsets');
             Properties.Add('ServerArgument4=--language=./share/spanish');
             Properties.Add('ServerArgument5=--skip-innodb');
             Properties.Add('ServerArgument6=--key_buffer_size=32M');
          end
          else begin
             HostName := fini.ReadString('Database', 'Host', '');
             Port     := fini.ReadInteger('Database', 'Port', 0);
             User     := fini.ReadString('Database', 'User', '');
             Password := fini.ReadString('Database', 'Password', '');
          end;
     end;
     fini.Free;
     try
        ZConnection1.Connect;
     finally
        ZConnection1.Disconnect;
     end;
Maybe this throws some light on what you need to do. Every other ZeosLib component have Connection property pointing to this ZConnection1.
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Re: Connect Zeoslib to Oracle

Post by Pitfiend »

To be able to connect to a remote server, in the hostname you put it's domain or ip address (also need to set the port), the rest stays as is. The Mysql server must be reachable, that means it must be in the same network space or expossed to the internet (something not so wise imho).
User avatar
GhostReaper
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 11.06.2014, 07:47
Location: South Africa

Re: Connect Zeoslib to Oracle

Post by GhostReaper »

Pitfiend wrote:To be able to connect to a remote server, in the hostname you put it's domain or ip address (also need to set the port), the rest stays as is. The Mysql server must be reachable, that means it must be in the same network space or expossed to the internet (something not so wise imho).
We are currently using a MySQL ODBC connection to connect remotely to our MySQL database which a BDE TDatabase component can pick up in Delphi2005 no problem. Our remote server is a linux machine and is hosted by an external company.

I have entered the hostname as the remote server's ip address, entered the database name, and the port number, password and user. I also selected the protocol which is 'mysql-5'. When I try and connect, it just brings up a error message that says the following:
Capture.PNG
Not sure what the last part of the message means. That code that you used as an example, where do I enter that code exactly?

I have managed to get it to connect to our Oracle DB now, just struggling with the remote MySQL part now.
You do not have the required permissions to view the files attached to this post.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Connect Zeoslib to Oracle

Post by marsupilami »

Hello GhostReaper,

it has been some time for me since I used Zeos with Oracle and it was only at one ocassion. But I would guess something like this:
Set the protocol property of your TZConnection Object to the oracle or oracle-9i protocol.
Keep the hostname property empty.
in the database name enter the name of your database from tnsnames.ora
set the username and password
choose a suitable connection character set encoding.

With best regards,

Jan
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Re: Connect Zeoslib to Oracle

Post by Pitfiend »

From what I see, you miss some DLLs, you need to put libmysql.dll in the same folder as your app or put it in a system path. If you don't have any DLL, you must download mysql zip file and have a look inside the lib folder for them (don't mix x32 with x64 binaries). There are 2 DLLs, one for remote connection (libmysql.dll) and the other for embeded database (libmysqld.dll) (this needs some tricks to run, if you want I can explain later). In hostname you need to put either an ip address or a formal url.

Hope this solves your troubles.
Post Reply