Oracle Database Client. Oracle instant client. Oracle Instant Client. Free, light-weight and easily installed Oracle Database libraries and SDKs for building and connecting client applications to local or remote Oracle Databases. Installing Oracle Client and Inserting TNS Connection file Full client 32 bit: http:// Full client 64 bit: http:// Also see my Stackoverflow http. SQL*Plus Instant Client is a standalone product with all the functionality of SQL*Plus command-line. It connects to existing remote Oracle databases, but does not include its own database. It is easy to install and uses. Installing PHP and the Oracle Instant Client for Linux and Windows For PHP 5.4 and Oracle Database 11g Release 2. 1 Oracle Database Client Installation Overview. This chapter describes the different types of Oracle Database Client installations that you can perform, and issues to consider before you install the software: Installation. Oracle Instant Client. Oracle Instant Client Instant Oracle Using C# - Code. Project. Connecting to Oracle using C# without using Oracle Developer Tools for Visual Studio . NET. Managing Oracle connectivity with a minimal footprint using Oracle Instant Client. Introduction. This is actually my first Code. Project article and my first attempt at writing C# code, so if I have made any mistakes along the way, please feel free to comment. I won't get offended ; )The idea behind this article was prompted because I found only one article that deals with C# and Oracle on this site (which is unrelated to my needs), and I haven't been able to find any articles anywhere else on the internet regarding this specific topic and platform. In order to properly use the information contained in this article, I am going to assume the following: You have at least a basic understanding of C# and have written code in it or some other language such as C++ or Java. You have a basic understanding of writing SQL commands. Have an Oracle database to connect to. If your database is at your place of work, a copy of tsanames. DB admin or whomever. I had, in the past, created an MFC application and used Oracle Objects for OLE to connect to the database in order to run my queries. I'm writing a little Excel VBA application on Windows XP that connects to a remote Oracle database. I have it working using the standard Oracle client using this connection string: oc.Open. While this worked, it required an insane amount of files to be installed along with my application, as well as some Registry entries. I really hated having to distribute all the extra files and complications along with it, but had no choice at the time. To put it simply, it required about 5. MB. Not exactly what I had in mind, but the documentation I had on how to use it wasn't very clear. And, I don't think there's an article to date on Code. Project on how to properly use it and what the client requires to have installed on his/her machine. Perhaps, someone will take up the challenge. In any case, now that I am gravitating towards using C#, I wanted to reattempt a few things I have done with Oracle, but leaving as little a footprint as possible on the client's computer. Just a few months prior to this article being written, I came across Oracle Instant Client (http: //www. This seemed like just what I was looking for. I spent the next few days trying to figure out how to use it with MFC. I can't recall the exact amount of time, but I can say this, it was far easier to implement with C# than C++, at least in my opinion. Oracle Instant Client uses OCI (Oracle call- level interface) for accessing Oracle databases. What is the Oracle Call Interface? The Oracle Call Interface (OCI) is an application programming interface (API) that allows applications written in C to interact with one or more Oracle servers. OCI gives your programs the capability to perform the full range of database operations that are possible with the Oracle. SQL statement processing and object manipulation. What you need? You will need to create a free account on Oracle's site (below) and agree to their terms to be able to download the client. Download Oracle Instant Client for Microsoft Windows (3. There are other platforms available, and a 6. Windows, but I haven't looked at the contents of any of those and they are outside the scope of this document anyhow. There are two versions you can choose from. They are: Basic and Basic- Lite. I recommend getting the Basic Lite version, unless you need to support more than the English language. OCCI requires only four dynamic link libraries to be loaded by the dynamic loader of the Operating System. When this article was written, it is using the 1. They are as follows: OCI Instant Client Data Shared Libraryoraociicus. Basic- Lite version)oraociei. Basic version)Client Code Library. Security Library. OCCI Library. The main difference between the two Instant Client packages is the size of the OCI Instant Client Data Shared Library files. The Lite version is roughly 1. MB, whereas the Basic version is almost 9. MB since it contains more than just the English version. Once you have these files, simply copy them into the same directory as your executable. You could possibly put them in another folder as long as your environmental variables are set to point to its path, but I found it easiest to do it this way. After all, it is only four files. The only other required file you will need to have is tsanames. DESCRIPTION = (ADDRESS = (PROTOCOL= TCP). Host= myserver. server. Port= your. Port#))(CONNECT. Also, you can expect to find multiple entries in this file so don't be surprised if there is more than one set. An alternative to including the tsanames. CONNECTION. Valid values for Integrated Security are: YES or TRUE to use external authentication, NO or FALSE to not use external authentication. Integrated Security=true Min Pool Size Specifies the minimum number of connections in the connection pool. Min Pool Size=0 Max Pool Size Specifies the maximum number of connections in the connection pool. Max Pool Size=1. 00 Pooling Specifies whether or not to use connection pooling. Valid values are TRUE or YES to use connection pooling, or FALSE or NOT to not use connection pooling. Pooling=true If you use Integrated Security, make sure you have a user created externally. Also, make sure you know what you are doing if you use external authentication - there are security implications. Read the Oracle Database Advanced Security Administrator's Guide for more info about external authentication. Code example - Connecting to Oracle and running a simple query. Once you have the above, the rest is easy. Create a new C# application. For this example, let's keep it simple and create it as a console application. Be sure to include a reference to System. Data. Oracle. Client. System. Data. Oracle. Client; This is a standard library provided by Microsoft. No voodoo witchcraft or additional Oracle library references are required. More information about this library can be found here. The following section of code should be all you need to get yourself started. This is simply an exercise in connecting to the database and running a simple SELECT query to return some data. The purpose of this article is to establish a connection to Oracle, installing as little as possible on a user's machine. You won't be seeing anything more complicated than that. We can save the rest for another article. We will start by creating two methods: static private string Get. Connection. String() and static private void Connect. And. Query(). I won't be going into any specific details regarding any of the code provided. There's plenty of documentation available to explain what can be done with System. Data. Oracle. Client, if you want more information. Get. Connection. String(). The code should otherwise be self- explanatory. All that remains is a call to Connect. And. Query() from Main. Errors you may run into at runtime. Error: Unhandled Exception: System. Data. Oracle. Client. Oracle. Exception. ORA- 1. 21. 54: TNS: could not resolve the connect identifier specified. Cause: Your connection string is invalid. Missing the tsanames. Resolution: Fix the connection string making sure the server name and/or credentials are correct. Make sure the tsanames. Error: Unhandled Exception: System. Exception. OCIEnv. Nls. Create failed with return code - 1 but error message. Cause: One or both of the required Oracle Instant Client DLLs are missing from the application's path. There is no 'PATH=' environmental variable set that points to these files should they not reside in the application's path. Resolution: Copy the DLLs into the application's path or modify your PATH= to include the directory where these files reside. Error: Unhandled Exception: System. Data. Oracle. Client. Oracle. Exception. ORA- 1. 27. 05: Cannot access NLS data files or invalid environment specified. Cause: You have Oracle or Oracle development tools installed locally (or on the machine running the application). Resolution: Check to see if . Chances are it does. Within the Oracle key, look to see if NLS. Providing a valid language such as AMERICAN. Single- byte character sets include US7. ASCII, WE8. DEC, WE8. MSWIN1. 25. 2, and WE8. ISO8. 85. 9P1. Unicode character sets include UTF8, AL1. UTF1. 6, and AL3. UTF8. Performance issues. I used both Oracle Developer Tools for Visual Studio . NET and Oracle Instant Client to experiment with. I did not noticeably see any performance differences during these tests although there may be some depending on what you are trying to do. For my purposes, there would be little gained by using the developer tools since it requires a more complex install and no noticeable performance gain. If anyone has any experiences they can share, please do. Conclusion. I hope this will help someone who needs to establish a connection to Oracle with their application and wishes to distribute it without any complicated client installs and with only a small footprint on the client's machine. Please feel free to leave comments and/or questions. If you have anything negative to say, please leave an explanation why. Otherwise, no one will learn from it. Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2016
Categories |