It's a bit empty. Let's summarize it with the new occi packages. This article is actually very useful, and it is a difficult topic for newcomers, for example, Oracle, unix, c ++, occi, shell, and makefile. Just pick out a noun and you will be able to learn it for a while. In this article, we will make a thorough analysis to connect oracle and program C ++ applications. On this basis, we will learn more about each noun point in the future and provide an entry-level function.
First, let's talk about my environment, I hope that you will be able to cope with various environments .) The company structure has to form the following work environment:
My host: windows + secureCRT, so I am using remote
Working HOST: unix + oracle (I am an oracle Server. In fact, the client has little problem and I will explain it in detail .)
Database Server: I only know the Host ip address, database username, and password. It should be a large host.
This kind of environment seems to be a three-way environment, but the actual work is two-way, because I remotely connect to a unix working machine using windows + secureCRT, write a c ++ program on unix to call occi to connect to a remote database server. Therefore, the focus of the description is the work of the latter two. For secureCRT (which can be another ssh tool) to connect to unix, you need the IP address, user name, and password of the unix host.
All of the following work begins with logging on to a unix worker. The goal is to compile, connect, and run c ++ code that connects to a remote oracle database on unix. Break through each other!
Step 1: compile, connect, and run the C ++ program to ensure that the C ++ environment is correct.
It's easy to judge whether the C ++ environment is correct. Write a helloworld. cpp program. The Code is as follows:
- # Include <iostream>
- Using NamespaceStd;
-
- Main ()
- {
- Cout <"Hello world! "<Endl;
- }
This code should contain elements different from c, such as using statements and cout;
In shell (both sh and bash are supported. Personally, bash is preferred .) Www.bkjia.com:
CC-c helloworld. cpp
(Note that CC is written in upper case and cc in lower case is compiled in C language ). The helloworld. o file is generated and the connection command is run:
CC-o helloworld. o
The result will generate the. out file by default, and the printed hello world will appear in the current directory./a. out! It is successful (do not miss the dot and slash./), and the compiling environment of C ++ is completed in this way. Don't worry, unix supports CC by default. As for gcc, unix developed by the gnu program on linux does not necessarily support it.