How to configure oracle instantclient for mono?
Mono is really awesome. Some of our applications worked in linux out of the box even without recompiling the binary. However I am having tough time to configure oracle instantclient to use it with mono.
I installed instantclient on a CentOS VM(by installing instantclient rpm) but however I did not find TNSNAMES.ORA anywhere.
I searched for oracle and I found the following path contains the oracle libraries.
[root@bagvapp rupert]# ll /usr/lib/oracle/11.2/client/lib/
total 143280
-rw-r--r-- 1 root root 7456 Aug 14 2009 cobsqlintf.o
-rw-r--r-- 1 root root 342 Aug 14 2009 glogin.sql
lrwxrwxrwx 1 root root 17 Mar 9 06:52 libclntsh.so -> libclntsh.so.11.1
-rw-r--r-- 1 root root 40088477 Aug 14 2009 libclntsh.so.11.1
-rw-r--r-- 1 root root 6986848 Aug 14 2009 libnnz11.so
lrwxrwxrwx 1 root root 15 Mar 9 06:52 libocci.so -> libocci.so.11.1
-rw-r--r-- 1 root root 1879549 Aug 14 2009 libocci.so.11.1
-rw-r--r-- 1 root root 89377610 Aug 14 2009 libociei.so
-rw-r--r-- 1 root root 152304 Aug 14 2009 libocijdbc11.so
-rw-r--r-- 1 root root 1501651 Aug 14 2009 libsqlplusic.so
-rw-r--r-- 1 root root 1218075 Aug 14 2009 libsqlplus.so
-rw-r--r-- 1 root root 777979 Aug 14 2009 libsqora.so.11.1
-rw-r--r-- 1 root root 1996228 Aug 14 2009 ojdbc5.jar
-rw-r--r-- 1 root root 2111220 Aug 14 2009 ojdbc6.jar
-rw-r--r-- 1 root root 298388 Aug 14 2009 ottclasses.zip
drwxr-xr-x 3 root root 4096 Mar 9 06:52 precomp
-rw-r--r-- 1 root root 37807 Aug 14 2009 xstreams.jar
no TNSPING available, no TNSNAMES.ORA, Now how to configure the mono to use this as the oracle client? and how to specify oracle database in app.config connection string section?
Though mono is a powerful framework, se开发者_如何学Cems like it is having problems like linux does, all the documentation is only available in mailing lists and whatever is available on official site is either outdated or not clear for normal user.
Hope things will change soon and Mono will THE programming framework for linux.
Use oracle easy connect naming method or create a tnsnames.ora yourself at the right location (check instant client docs for search order of locations). tnsping is not part of instant client (or any add on package).
From the instant client faq How do I ensure that my "tnsnames.ora" file is being used in Instant Client? Always set the TNS_ADMIN environment variable or registry setting to the full path of the tnsnames.ora file. This practice will ensure that you are using the appropriate tnsnames.ora for your application when running with Instant Client.
How do I specify connection strings in Instant Client mode? All Oracle net naming methods that do not require use of ORACLE_HOME or TNS_ADMIN (to locate configuration files such as tnsnames.ora or sqlnet.ora) work in the Instant Client mode. In particular, the connect string can be specified in the following formats:
A SQL Connect URL string of the form:
//host:[port][/service name]
such as:
//dbase-server-5:4321/ORDERS
As an Oracle Net keyword-value pair. For example:
"(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=dlsun242) (PORT=5521)) (CONNECT_DATA=(SERVICE_NAME=bjava21)))"
Naming methods that require TNS_ADMIN to locate configuration files continue to work if the TNS_ADMIN environment variable is set.
If the TNS_ADMIN environment variable is not set, and TNSNAMES entries such as inst1, and so on, are used, then the ORACLE_HOME variable must be set, and the configuration files are expected to be in the $ORACLE_HOME/network/admin directory.
Please note that the ORACLE_HOME variable in this case is only used for locating Oracle Net configuration files, and no other component of Client Code Library (OCI, NLS, and so on) uses the value of ORACLE_HOME.
The bequeath adapter or the empty connect strings are not supported. However, an alternate way to use the empty connect string is to set the TWO_TASK environment variable on UNIX, or the LOCAL variable on Windows, to either a tnsnames.ora entry or an Oracle Net keyword-value pair. If TWO_TASK or LOCAL is set to a tnsnames.ora entry, then the tnsnames.ora file must be able to be loaded by TNS_ADMIN or ORACLE_HOME setting.
Mono doesnt know where to search for "libclntsh.so". On my system "libclntsh.so" is available @ /usr/lib/oracle/11.2/client/lib/ . My problem got solved by executing the following command
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib/
精彩评论