Oracle Connection

I’m getting ARGen working with Oracle (hopefully) and I’m running into issues. The Oracle website is less than useful or perhaps I just don’t know the terminology well enough to do anything (seems like Greek to me).

I’ve had Oracle Express 10 installed in Windows 7 in a VM environment. I can get to it and manipulate the database via the Oracle Application Express (web) application they supply. I can connect to it via NaviCat for Oracle from the Mac side of the same machine and via Windows from another Win7 environment on a different machine.

I believe I have the client libraries installed properly on the Mac and the following set in app.open event:

System.EnvironmentVariable("DYLD_LIBRARY_PATH")="/usr/local/oracle"

I’ve tried using the IP Host/Port/DB/Username/PW in the traditional Xojo way and I’ve also tried using the way described in the Xojo documentation in the Host field of “(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.17)(PORT=1521))(CONNECT_DATA=(SID=XE)))”

Each time all I get is an error message like this: Server Response: ORA-12154: TNS could no resolve the connection identifier specified.

Anyone ever get the Mac client to talk to instance of Oracle? Anyone have any hints that I can try?

EDIT: I’ve even tried running the app in Windows and it can’t connect so I must be missing something fairly basic in the Xojo setup.

Is there an entry in TNSNAMES.ORA where your database is called XE?

Did you read this?
http://www.mbsplugins.de/archive/2013-03-28/MBS_Real_Studio_SQL_Plugin_and/monkeybreadsoftware_blog_archive
and
http://www.monkeybreadsoftware.net/faq-howtoavoidtroubleconnectingtooracledatabasewithsqlplugin.shtml

The environment variable was a problem as it can’t be set in the app right. Also connection string must be right.
For one my tests it looks like
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.244.11)(PORT=1521))(CONNECT_DATA=(SID=XE)))
which looks like yours except the IP.

But did you try just a connections string like [:][/<service_name>] format?

[quote=39701:@Bob Keeney]I believe I have the client libraries installed properly on the Mac and the following set in app.open event:

System.EnvironmentVariable(“DYLD_LIBRARY_PATH”)="/usr/local/oracle"[/quote]

I think that setting the environment here in the app.open it’s too late. I had the same idea on Linux and that didn’t work either.
You can simply try in a bash session to set this environment variable and after that in the same bash session try to start your application.
In Linux it worked that way without a problem.
If this works also for you then the solution would be to set the environment system-wide but i don’t know how to do that in OSX, however i think that in the explanation from Christian is the solution (copy from his link):
On Mac OS X you also need to define DYLD_LIBRARY_PATH to point to the dylib files from oracle.

For that you need to modify /etc/launchd.conf for Mac OS X 10.8 and newer.
In older versions those variables in .MacOSX/environment.plist file in user’s home.

The Oracle instance is in Windows. I finally got into the tnsnames.ora and the string was thus:

(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = BOBKEENEYFA47)(PORT = 1521) (CONNECT_DATA =(SERVER = DEDICATED (SERVICE_NAME = XE) ))

Using this had zero effect on the Mac or Windows debug runs with the Windows version on the same machine Oracle is on. I tried a couple of different variations like using tcp/ip for the host but to no avail.

If the path is wrong, or the library can’t be found at the path it will give a specific error message (at least on Mac OS X) about not being able to find the library so I think that part is working.

I don’t think the path is wrong, as soon as app.open fires the oracle plugin is alraedy initialized and didn’t see it’s environment path set, that’s why i think it’s too late.

I give up. This exercise was to help a user out with ActiveRecord generator. I’ve already spent way more time on it that there are users of Oracle in the Xojo world. :frowning:

I cannot connect to an Oracle database from a Xojo application. Doesn’t matter if it’s Mac or Windows.

Bottom line is that the documentation for the Oracle Plugin is severely lacking and few people with experience in connecting to Oracle from a Xojo application. Add in the hieroglyphics that called an Oracle website and I’ll move on to things I can actually do.

This worked for me !

ORACLE for XOJO WIN7

Download 32 Bit Oracle Instant Client for Win7 (instantclient-basic-nt-11.2.0.3.0.zip)

Optional: Download SQL-Plus (instantclient-sqlplus-nt-11.2.0.3.0.zip)
Download ODBC (instantclient-odbc-nt-11.2.0.3.0.zip)

Unzip all files

Merge the content of the three Folder in one Folder !

Name this Folder appropriate (for example: ORACLE).

Move this ORACLE-Folder wherever you want (for example: C:).

Add the Path to this ORACLE-Folder to the PATH Variable.

Move the tnsnames.ora into the ORACLE-Folder

Create a new environment variable TNS_ADMIN with the path to the ORACLE-Folder

ODBC: Download Microsoft Visual C++ 2010 Redistributable Package (x86) (vcredist_x86.exe)
Run installer
Run odbc_install.exe in ORACLE-Folder
To configure ODBC run odbcad32.exe in C:\Windows\SysWOW64

GO !

ORACLE for XOJO MAC will follow

[quote=40286:@Stefan Cyrus]ODBC: Download Microsoft Visual C++ 2010 Redistributable Package (x86) (vcredist_x86.exe)
Run installer
Run odbc_install.exe in ORACLE-Folder
To configure ODBC run odbcad32.exe in C:\Windows\SysWOW64[/quote]

So you’re using ODBC rather than the native Oracle plugin?

Otherwise, awesome tutorial! I will have to give this a try when I get a chance.

Hello Bob

I use both (OCI with Oracle plugin and ODBC) but with OCI I cannot retrive the ORACLE “ROWID”, I allways get NULL !!!
I can send you some lines of codes for connecting to an Oracle DB via OCI ?.

This worked for me !

ORACLE for XOJO MAC (OCI)

Download 32 Bit Oracle Instant Client for MAC (instantclient-basic-10.2.0.4.0-macosx-x86.zip)

Unzip

Name this Folder appropriate (for example: ORACLE).

Copy (in this Folder) libclntsh.dylib.10.1, and rename the copy to libclntsh.dylib.

Copy (in this Folder) libocci.dylib.10.1, and rename the copy to libocci.dylib.

Move the tnsnames.ora into the ORACLE-Folder

Move this ORACLE-Folder wherever you want (for example: /Library).

In your XOJO Programm add following lines:

System.EnvironmentVariable(“ORACLE_HOME”) = /Library/ORACLE
System.EnvironmentVariable(“DYLD_LIBRARY_PATH”) = /Library/ORACLE
System.EnvironmentVariable(“TNS_ADMIN”) = /Library/ORACLE

GO !

ORACLE for XOJO MAC (ODBC)

Use: Actual ODBC Driver for Oracle

Windows 7 + Oracle via Oci

This run fine for me:

1. I download the oracle cliente for free

Version 10.2.0.3
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
Download instantclient-basic-win32-10.2.0.3-20061115.zip (34,469,920 bytes)

http://www.oracle.com/technetwork/topics/winsoft-085727.html

  1. create a folder called “C:\oracle”
  2. unzip the instantclient-basic-win32-10.2.0.3-20061115.zip in the folder “C:\oracle”
  3. Set the windows environment the variable ORACLE_HOME=“C:\oracle”
  4. Add “;C:\oracle” to the path of the windows environment variable
    for an example visit the url: http://www.itechtalk.com/thread3595.html
  5. Use the Oracle example in the xojo ide;

mDb = New OracleDatabase

mDb.DatabaseName = “(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.1.14)(PORT=1521))(CONNECT_DATA=(SID=XE)))”
mDb.UserName = “SYSTEM”
mDb.Password = “dbexample”
mDB.Debug = 1

If mDb.Connect Then
mIsConnected = True
ConnectStatusLabel.Text = “Connected to Oracle!”
Else
mIsConnected = False
ConnectStatusLabel.Text = "Error connecting to Oracle: " + mDb.ErrorMessage
End If

Bob: A little off topic, but do ActiveRecord and ARGen support ODBC?

from my MAC.

here is the list of databases ARGen 1.6.4 supports. Which should be the current version or very close to it.

It currently does NOT support ODBC. However, I don’t see why it couldn’t do ODBC using the Xojo has a plugin for it.

We have no plans for ODBC but we could do a small consulting project for you to do so. Or, you can take a stab at doing it yourself. Look for where we deal with all the various databases and at that point it’s a matter of duplicating the code. Mostly that will be the database adapter classes but there are a handful of other places in the code too.

ActiveRecord itself is open source and you don’t need ARGen to create the Data classes (it’s just more convenient).

Thanks for the info Scott and Bob.