Recent

Author Topic: Problem connecting Lazarus with oracle 11g XE  (Read 13551 times)

wgandalf

  • Newbie
  • Posts: 4
Problem connecting Lazarus with oracle 11g XE
« on: November 22, 2012, 02:38:54 am »
I've tried to connect oracle with lazarus and I this error appeared:

oracleconnection1: The creation of an oracle environment failed

Lazarus: v 1.0.2
Version FPC: 2.6.0
Oracle 11g XE 11.2.0
Windows XP SP3 32B.

procedure TForm1.Button1Click(Sender: TObject);
begin
  with OracleConnection1 do
  begin
    directory := directorio.Text;
    hostname := '';
    Databasename :=  host.Text+':'+puerto.Text+'/'+sid.Text;//'localhost:1521/xe';
    Connected := true;
  end;
  if OracleConnection1.Connected then
   showmessage('Conectado.');
   sql.Active:=true;
end;     

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #1 on: November 22, 2012, 08:31:19 am »
2 remarks:
1. Are your connection parameters correct (e.g. are you sure you don't need to fill in hostname, even 127.0.0.1 or localhost?)
2. Is your Oracle driver installed and working? Can you e.g. connect with sql*plus?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

wgandalf

  • Newbie
  • Posts: 4
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #2 on: November 22, 2012, 01:49:11 pm »
1. Are your connection parameters correct (e.g. are you sure you don't need to fill in hostname, even 127.0.0.1 or localhost?)
  I don't know its my first time with lazarus and oracle. I found this code and some similar.
2. Is your Oracle driver installed and working? Can you e.g. connect with sql*plus?
 Oracle Drivers work. Yes, sqlplus work.

sorry for my English.

wgandalf

  • Newbie
  • Posts: 4
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #3 on: November 22, 2012, 01:51:02 pm »
Probe with multiple servers I have and always returns the same error

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #4 on: November 22, 2012, 03:37:13 pm »
Well, given the example in FPC's database.ini.txt template file for the sqldb test framework, I would use the Hostname property and specify 127.0.0.1, possibly followed by :<port> if that isn't 1521.

The databasename may be the SID, don't know exactly. xe is what is mentioned in the database.ini.txt as well which is presumably set up for an Oracle XE setup.

Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

denver

  • Jr. Member
  • **
  • Posts: 67
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #5 on: November 22, 2012, 06:53:50 pm »

The databasename may be the SID, don't know exactly. xe is what is mentioned in the database.ini.txt as well which is presumably set up for an Oracle XE setup.


Oracle' s databasename concept is different from MySQL, PostgreSQL..., you need to assign the access right for each user.
I use ZeosLib to connect to Oracle 11g XE with the following setting ( Localhost ) :

ZConnection1.DatabaseName := '127.0.0.1'  ;
ZConnection1.Port : 1521 ;
ZConnection1.HostName := '127.0.0.1' ;
ZConnection1.UserName := 'yourusername' ;
ZConnection1.Password := 'yourpassword' ;
ZConnection1.Protocol := 'oracle' ;

It work fine for me ....

wgandalf

  • Newbie
  • Posts: 4
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #6 on: November 22, 2012, 07:18:58 pm »
ok, i will googlear zeoslib. Thanks

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #7 on: November 23, 2012, 09:09:56 am »
Yes, by all means Google another db library instead of following my suggestions with the library you have now. Then you'll probably copy/paste some code that won't quite work and you end up asking the same kind of questions :(

I'm giving up.
(Glad I didn't spend any effort in e.g. converting a demo app to Oracle as I had done before)

@denver: I don't know what you mean by your database name remark - but it's not relevant now anyway...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

denver

  • Jr. Member
  • **
  • Posts: 67
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #8 on: November 23, 2012, 12:34:28 pm »
Oracle use the concept of workspace instead of database, so databasename is not valid in ZConnection1.databasename.
Just put ZConnection1.DatabaseName := 'host ip address'  is ok.

The workspace concept make me crazy  >:( when i start to work with oracle.


BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Problem connecting Lazarus with oracle 11g XE
« Reply #9 on: November 23, 2012, 01:32:22 pm »
Workspace? No idea what you mean by that, but haven't kept track since 10g.
Instance/sid, schema & database: yes. Workspace? No.
Anway, feel free to update http://wiki.lazarus.freepascal.org/oracle with a zeos and/or sqldb section if you want to, that will certainly help.

Regarddless, I'm sure Zeos' Zconnection.databasename is different from sqldb's toracleconnection.databasename...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018