Recent

Author Topic: Zeos com Oracle  (Read 3716 times)

Emerson

  • New Member
  • *
  • Posts: 31
Zeos com Oracle
« on: August 02, 2021, 11:52:05 pm »
Hi!
I'm trying to connect to oracle database using Lazarus with Zeos, but I'm not getting it. In Lazarus I put the TZconnection component and define the following data:
database MyBank
Hostname: 192.168.0.46
Port 1521
user dev
password 123456
Oracle protocol
And when you click connected, the following message appears:
"SQL Error: OCI_ERROR: ORA-12154: TNS:could not resolve the connect identifier specified"
Note: I have already downloaded the oracle client corresponding to the server version and I am using the correct dlls.
Can someone help me?

GAN

  • Sr. Member
  • ****
  • Posts: 337
Re: Zeos com Oracle
« Reply #1 on: August 03, 2021, 12:03:47 am »
You may have forgotten to indicate the location of the library (dll) in the "LibraryLocation" property of TZConnection.
Lazarus 2.0.8 FPC 3.0.4 Linux Mint Mate 19.3
Zeos 7̶.̶2̶.̶6̶ 7.1.3a-stable - Sqlite 3.32.3 - LazReport

https://searchlazarus.blogspot.com/

Emerson

  • New Member
  • *
  • Posts: 31
Re: Zeos com Oracle
« Reply #2 on: August 03, 2021, 12:11:09 am »
Hi! Many thanks for the reply. Yes, I already indicated the path to the library, the error persists

marsupilami79

  • New Member
  • *
  • Posts: 12
Re: Zeos com Oracle
« Reply #3 on: August 03, 2021, 08:04:49 am »
Hello Emerson,

Hi!
I'm trying to connect to oracle database using Lazarus with Zeos, but I'm not getting it. In Lazarus I put the TZconnection component and define the following data:
database MyBank
Hostname: 192.168.0.46
Port 1521
user dev
password 123456
Oracle protocol
And when you click connected, the following message appears:
"SQL Error: OCI_ERROR: ORA-12154: TNS:could not resolve the connect identifier specified"

As far as I know, you don't need to set hostname and port with the oracle driver. It uses the aliases from tnsnames.ora. So make sure, you have a working alias in tnsnames.ora and then put the alias name into the database property of TZConenction. If that doesn't work, please ask on the Zeoslib forums. Somebody there might be able to help you.

Best regards,

Jan

Emerson

  • New Member
  • *
  • Posts: 31
Re: Zeos com Oracle
« Reply #4 on: August 03, 2021, 08:32:41 am »
The server already has an alias, so much so that in Delphi using Firedac I can connect. I tried running your tip, but it didn't work either. As you told me, I'm going to open a ticket on the Zeos forum. Thank you very much!

devEric69

  • Hero Member
  • *****
  • Posts: 572
Re: Zeos com Oracle
« Reply #5 on: August 03, 2021, 02:50:05 pm »
Hello, for info., you could perhaps check (again?):

- is the Oracle client really well installed on your client computer (at the most simple i.e. - amho - with "no service creation", "runtime mode", "custom mode to choose ODBC", "Oracle Windows interfaces x.x.x.x" checked, so an installed driver that can be used by ODBC then, and is the communication protocol selected as "sql net" (it's fairly one of the simplier, AFAIK)?
- is the file tnsnames.ora in your C:\ora920\network\admin, on your client side (ora920 as an example, depending from your client-side installation path, and your Oracle 's version)?
- is the listening communication server port number correct, as Oracle has registered it within the international organization IANA (I've just checked: 1521 seems correct; I was using a server with port number = 2030, which was the default port number proposed during the installation)?
- have you tested in ODBC connections control panel too (under MS-Windows, there should be a "Test connection" button, beside the ODBC connections), by creating a connection with the simplest options: "read-only connection", "disable MT Server"", and NLS_SORT=BINARY, NLS_NUMERIC_CHARACTERS=',.' if possible (the last two options are stored in registry, but it depends on the Oracle's version, IIRC).
- does the local client driver work? You could run "tnsping ora8.world" in a DOS-cmd (if the data source - created in the ODBC connections control panel, from the good choosen installed ODBC Oracle driver - is called\named 'ora8.world', for example), it should respond 'OK<180 ms>'. The tiny tool "tnsping" also allows you to see on which eventual exotic port your server would have been installed (remember to test without a firewall on the client computer, too)? AFAIK, tnsping is the best tool to know if the driver AND your tnsnames.ora are OK, to communicate with your server, from your client computer!

Last trick: from Oracle 10 onwards, under MS-Windows (8, ...? I don't remember in which context), it was sometimes necessary to assign your Oracle user to the group of users authorised to use the created ODBC entry (in "local security policy strategy" of MS-Windows).


Hopefully it might help.
« Last Edit: August 04, 2021, 09:42:03 am by devEric69 »
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Emerson

  • New Member
  • *
  • Posts: 31
Re: Zeos com Oracle
« Reply #6 on: August 03, 2021, 03:57:42 pm »
Hi!
I managed to solve it according to the example below:

z_conexao.Connected := False;
z_conexao.Database := '192.168.0.46/orcl';
z_conexao.HostName := MyBank;
z_conexao.LibraryLocation := 'C:\Windows\oci.dll';
z_conexao.Port := 1521;
z_conexao.User := 'teste';
z_conexao.Password := '123456';
z_conexao.Protocol := 'oracle';
z_conexao.LoginPrompt := False;
z_conexao.Connected := True;

I was testing one by one until I got the parameters right. The strange thing is that the parameters work in an inverted way, that is, in the database I put the hostname information and in the hostname I put the database information. I don't know why, but that way it worked. Thanks to everyone who tried to help me!

devEric69

  • Hero Member
  • *****
  • Posts: 572
Re: Zeos com Oracle
« Reply #7 on: August 03, 2021, 04:18:22 pm »
Well done!
use: Linux 64 bits (Ubuntu 20.04 LTS).
Lazarus version: 2.0.4 (svn revision: 62502M) compiled with fpc 3.0.4 - fpDebug \ Dwarf3.

Emerson

  • New Member
  • *
  • Posts: 31
Re: Zeos com Oracle
« Reply #8 on: August 03, 2021, 07:15:51 pm »
Thank you!

 

TinyPortal © 2005-2018