<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi GianLuca,<br><br>I had difficulties getting Oracle Express to work with unixODBC in May this year (2009).<br>Here are the last two emails to Nick about it. The last explains what the problem was. I am not sure though if you are having the same problem.<br>&nbsp; <br><br>+++++&nbsp; email to Nick begins ++++++<br>I have DB2, MySQL, Mimer SQL and SQL Anywhere connect successfully via unixODBC on Ubuntu 8.10, but Oracle Express 10g is giving me a hard time.<br><br><br>I am getting this error on SQLConnect when trying to connect to Oracle's HR sample database on my local PC:<br><br>Usage error: SQLConnect: dsn=TestDBDSN, user=hr, password=hr &lt;&lt;-- by my code<br>1: st=IM004, nerr=0, msg=<br>[unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed<br><br>for:<br><br>/etc/odbcinst.ini<br>[OracleExpressdrv]<br>Driver =
 /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libsqora.so.10.1<br>Description = Oracle 10g express driver<br><br>/etc/odbc.ini<br>[TestDBDSN]<br>Application Attributes = T<br>Attributes = W<br>BatchAutocommitMode = IfAllSuccessful<br>CloseCursor = F<br>DisableDPM = F<br>DisableMTS = T<br>Driver = OracleExpressdrv<br>DSN = TestDBDSN<br>EXECSchemaOpt =<br>EXECSyntax = T<br>Failover = T<br>FailoverDelay = 10<br>FailoverRetryCount = 10<br>FetchBufferSize = 64000<br>ForceWCHAR = F<br>Lobs = T<br>Longs = T<br>MetadataIdDefault = F<br>QueryTimeout = T<br>ResultSets = T<br># ServerName is TNS_alias_from_tnsnames.ora<br>ServerName = XE<br>SQLGetData extensions = F<br>Translation DLL =<br>Translation Option = 0<br>UserID = hr<br><br><br><br>I have posted about this in Oracle Linux forum, Oracle Express forum and on DBforums forum, but no one seems to know.<br><br>I have googled for days on 'IM004' and 'SQLAllocHandle on SQL_HANDLE_HENV failed' etc and
 received matches, but most of them old, for Windows or other db products. Some posts have suggested 'set environment variable so-and-so', which I have done by adding to the bash login script. These<br><br>#&nbsp; Added by ken for oracle<br><br>ODBCINI=/etc/odbc.ini;export ODBCINI<br>ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0;export ORACLE_HOME<br>TNS_ADMIN=$ORACLE_HOME/server/network/admin;export TNS_ADMIN<br>LD_LIBRARY_PATH=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib;export LD_LIBRARY_PATH<br><br>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin:/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin<br><br>but still no luck.<br><br><br>Oracle® Database<br>Administrator’s Reference<br>10g Release 2 (10.2) for UNIX-Based Operating Systems<br>B15658-06<br>March 2009<br><br>contains
 information about ODBC using unixODBC in appendix G, but none of it helped. I have not found any other Oracle documentation about ODBC for Linux. The Oracle Admin Reference says that error messages formatted [unixODBC][Driver Manager]message-text are output by the unixODBC driver manager, so I checked and found that the message text 'Driver's SQLAllocHandle on SQL_HANDLE_HENV failed' is set in _info.c, post_internal_error for case ERROR_IM004.<br><br>It is hard for me to understand the unixodbc driver code. Is there any error information coming from the Oracle driver that may hint at a solution? Do you know if anyone has managed to connect to Oracle Express on Linux?<br><br>I really don't want to give up on this, but...<br><br>Ken<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>P.S. when googling I found some posts containing unixODBC tracing code.<br>How do I turn tracing ON?<br>++++++&nbsp; email to Nick ends&nbsp; ++++<br><br><br>+++ last email to Nick about
 this problem begins ++++++<br><br>Nick,<br><br>I asked for your assistance to connect to Oracle Express and you suggested I run strace. That eventually solved the problem. Many thanks for that!<br><br>The problem was that Oracle had changed the install directory structure (undocumented?). I discovered by trial and error that ORACLE_HOME has to be:<br><br>ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server<br><br>not<br><br>ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0<br><br>which is indicated in dozens of pages on the Internet going back many years.<br>&nbsp;&nbsp;&nbsp; <br>I am using code::blocks IDE for programming on Ubuntu/Linux. It is a good IDE and it has served me well. I have ported several 100+ file projects from Windows and my current project developed on codeblocks connects to DB2, MySQL, Mimer SQL and SQL Anywhere via unixODBC, but Oracle is still giving me a problem. The Oracle connect works from the command
 line but not from codeblocks.<br><br>I have posted about this on the codeblocks General forum, but not received any responses that have helped. The section below is taken from that forum.<br><br>++++ post on codeblocks forum begin +++<br>For Ubuntu 8.10. using codeblocks rev 5607 (the latest).<br><br>The program connects ok via ODBC to Oracle Express on the Ubuntu commandline:&nbsp;&nbsp; <br><br>ken@ken-desktop:~/projects/lsken/bin/Debug$ ./lsken2<br>ODBC connected OK &lt;&lt; my tracemessage<br><br><br>but not from codeblocks Run in Build menu or Start on Debug menu. I receive error:<br><br>Can't open lib /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib/libsqora.so.10.1<br><br>The so file is the Oracle ODBC driver and the unixODBC driver manager outputs the message.<br><br>I have written a minimal test program (THISAPP) in main.cpp that shows the problem:<br><br>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br>#include
 "sql.h"<br>#include "sqlext.h"<br><br>static void dspmessage ( const char * title , const char * msg )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; printf ( "%s: %s " , title , msg ) ;<br>&nbsp;&nbsp; printf ( "Press Return/Enter to continue\n" ) ;<br>&nbsp;&nbsp; getchar ( ) ;&nbsp; //to wait<br>&nbsp;&nbsp; }<br><br>static void sqlerrinfo ( int handletp , int handle , const char * logstring )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; char txt [ 4002 ] ;<br>&nbsp;&nbsp; int maxlen = 4000 ;<br>&nbsp;&nbsp; int ofs = sprintf ( txt , "%s\n" , logstring ) ;<br>&nbsp;&nbsp; int recnbr = 1;<br>&nbsp;&nbsp; long nerr ;<br>&nbsp;&nbsp; short lenerrmsg ;<br>&nbsp;&nbsp; int ln ;<br>&nbsp;&nbsp; unsigned char state [ 12 ] = { 0 } ;<br>&nbsp;&nbsp; unsigned char msg [ SQL_MAX_MESSAGE_LENGTH+1 ] = { 0 } ;<br>&nbsp;&nbsp; char line [ 802 ] = { 0 } ;<br>&nbsp;&nbsp; int rc = SQL_SUCCESS ;<br>&nbsp;&nbsp; while ( rc != SQL_NO_DATA_FOUND)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rc = SQLGetDiagRec ( handletp , (SQLHANDLE)handle , recnbr ,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state, &amp;nerr , msg , SQL_MAX_MESSAGE_LENGTH ,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;lenerrmsg ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ln = sprintf ( line , "%d: st=%s, nerr=%d, msg=\n%s\n" ,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; recnbr , state , (int)nerr , msg ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( ln+ofs &lt; maxlen )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy ( txt+ofs , line )
 ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ofs += ln ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; recnbr++; // for next diagnostic record.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; dspmessage ( "usage error" , txt ) ;<br>&nbsp;&nbsp; }<br><br>static bool success ( SQLRETURN rc )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; return (rc == SQL_SUCCESS) || (rc == SQL_SUCCESS_WITH_INFO) ;<br>&nbsp;&nbsp; }<br><br>static bool connectSrv ( const char * dsn , const char * uid , const char * pwd )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; SQLHENV henv;<br>&nbsp;&nbsp; SQLRETURN rc = SQLAllocHandle ( SQL_HANDLE_ENV , SQL_NULL_HANDLE , &amp;henv ) ;<br>&nbsp;&nbsp; if ( !success ( rc )
 )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dspmessage ( "sqlapi" , "SQLAllocHandle Env failed" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp; rc = SQLSetEnvAttr ( henv, SQL_ATTR_ODBC_VERSION , (void*)SQL_OV_ODBC3 , 0 ) ;<br>&nbsp;&nbsp; if ( !success ( rc ) )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlerrinfo ( SQL_HANDLE_ENV , (int)henv , "Set ODBC version fail" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLFreeEnv ( henv ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ;<br><br>&nbsp;&nbsp; SQLHDBC hdbc;<br>&nbsp;&nbsp; rc = SQLAllocHandle ( SQL_HANDLE_DBC , henv , &amp;hdbc ) ;<br>&nbsp;&nbsp; if ( !success ( rc ) )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlerrinfo ( SQL_HANDLE_ENV , (int)hdbc , "Alloc connection handle error" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 SQLFreeEnv ( henv ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ;<br><br>&nbsp;&nbsp; SQLSetConnectAttr ( hdbc , SQL_LOGIN_TIMEOUT , (void*)5 , 0 ) ;<br><br>&nbsp;&nbsp; char msg [ 100 ] ;<br>&nbsp;&nbsp; rc = SQLConnect ( hdbc , (SQLCHAR*)dsn , SQL_NTS,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SQLCHAR*) uid , SQL_NTS,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SQLCHAR*) pwd , SQL_NTS);<br>&nbsp;&nbsp; if ( !success ( rc ) )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sprintf ( msg , "SQLConn: dsn=%s user=%s pwd=%s\n" , dsn , uid , pwd ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlerrinfo ( SQL_HANDLE_DBC , (int)hdbc , msg ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLFreeConnect ( hdbc )
 ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLFreeEnv ( henv ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dspmessage ( "sqlapi" , "SQLConnect failed" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ;<br><br>&nbsp;&nbsp; SQLHSTMT hstmt;<br>&nbsp;&nbsp; rc = SQLAllocHandle ( SQL_HANDLE_STMT , hdbc , &amp;hstmt);<br>&nbsp;&nbsp; if ( !success ( rc ) )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlerrinfo ( SQL_HANDLE_DBC , (int)hdbc , "Alloc Stmt error" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLDisconnect ( hdbc ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLFreeConnect ( hdbc ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SQLFreeEnv ( henv ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } ;<br>&nbsp;&nbsp; return true ;<br>&nbsp;&nbsp; }<br><br>int main ( int argc , char * argv[] )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp; if ( connectSrv ( "TestDBDSN"&nbsp; , "hr" , "hr" )
 )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dspmessage ( "sqlapi" , "ODBC Connect OK\n" ) ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp; return 0 ;<br>&nbsp;&nbsp; }<br>+++ post to codeblocks forum ends ++++<br><br>+++++ last email to Nick ends +++++<br><br><br>So after many days I managed to get Oracle XE to work, but I have actually not used it yet!<br><br>Hope this may be of some use.<br><br>Ken<br><br><br><br><br><br><br>--- On <b>Tue, 29/12/09, GianLuca Sarto <i>&lt;glsarto@tiscali.it&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: GianLuca Sarto &lt;glsarto@tiscali.it&gt;<br>Subject: Re: [unixODBC-support] how to connect to oracle xe?<br>To: "Support for the unixODBC project" &lt;unixodbc-support@mailman.unixodbc.org&gt;<br>Date: Tuesday, 29 December, 2009, 6:58 PM<br><br><div class="plainMail">Nick,<br><br>thanks for your kind
 reply.<br><br>I am not sure I fully understood the Oracle ReadME, but I managed to install the driver.<br><br>Well, almost...<br><br>ODBCConfig crashes when I try to configure the driver:<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ sudo ODBCConfig<br>ODBCConfig: libltdl/ltdl.c:1178: try_dlopen: Assertion `filename &amp;&amp; *filename' failed.<br>Aborted<br><br>This is what I've done:<br><br>1. ensured that instant client was setup:<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ ./sqlplus user/pwd@//192.168.1.126:1521/XE<br><br>2. make script executable:<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ sudo chmod a+x odbc_update_ini.sh<br><br>3. run script:<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ sudo ./odbc_update_ini.sh /<br><br>4. content of odbc.ini<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ cat /etc/odbc.ini<br>[oracle]<br>Driver&nbsp; &nbsp; &nbsp; &nbsp; =
 /usr/lib/oracle/instantclient_10_2/libsqora.so.10.1<br>Database&nbsp; &nbsp; = //192.168.1.126:1521/XE<br>User&nbsp; &nbsp; &nbsp; &nbsp; = user<br>Password&nbsp; &nbsp; = pwd<br><br>5. content of odbcinst.ini<br>gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ cat /etc/odbcinst.ini<br>[Oracle 10g ODBC driver]<br>Description&nbsp; &nbsp;&nbsp;&nbsp;= Oracle ODBC driver for Oracle 10g<br>Driver&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = /usr/lib/oracle/instantclient_10_2/libsqora.so.10.1<br>Setup&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;=<br>FileUsage&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;=<br>CPTimeout&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;=<br>CPReuse&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;=<br><br>I must have missed something...<br>-Gian<br><br>Nick Gorham wrote:<br>&gt; GianLuca Sarto wrote:<br>&gt;&gt; Hello All,<br>&gt;&gt; <br>&gt;&gt; I was ready to leave my XP Desktop and move it to Ubuntu Karmic, when I realized that I never tried my OpenOffice Base queries on
 Linux.<br>&gt;&gt; <br>&gt;&gt; I installed the Oracle Instant Client Basic and Odbc, and it works, i.e. I can connect to our Oracle XE database with SqlPlus.<br>&gt;&gt; <br>&gt;&gt; However, no matter how I googled, I wasn't able to find a tutorial or how-to setup the Oracle driver with UnixOdbc. gian@hp-gls:/usr/lib/oracle/instantclient_10_2$ sudo ODBCConfig<br>&gt;&gt; ODBCConfig: libltdl/ltdl.c:1178: try_dlopen: Assertion `filename &amp;&amp; *filename' failed.<br>&gt;&gt; Aborted<br>&gt;&gt; <br>&gt;&gt; I did find that Easysoft has commercial solutions for this issue, but I can't afford 1500 euro: I'd rather keep my XP desktop... :-(<br>&gt;&gt; <br>&gt;&gt; thanks for your time,<br>&gt;&gt; -GianLuca<br>&gt; I think the XE driver itself contains docs about setting up with unixODBC<br>&gt; <br><br>_______________________________________________<br>unixODBC-support mailing list<br><a ymailto="mailto:unixODBC-support@mailman.unixodbc.org"
 href="/mc/compose?to=unixODBC-support@mailman.unixodbc.org">unixODBC-support@mailman.unixodbc.org</a><br><a href="http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support" target="_blank">http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support</a><br></div></blockquote></td></tr></table><br>
      <hr size=1> <a href="http://sg.rd.yahoo.com/aa/mail/domainchoice/mail/signature/*http://mail.promotions.yahoo.com/newdomains/aa/"> New Email addresses available on Yahoo! </a> <br>
Get the Email name you&#39;ve always wanted on the new @ymail and @rocketmail.<br>
Hurry before someone else does!