search
HomeDatabaseMysql TutorialUNIX(Linux适用)环境下使用occi远程连接Oracle数据库

最后一步了,和远程数据库交互编程。哈哈,说是交互编程,只负责登陆成功而已。第三步,程序中登陆远程数据库。1、验证unix有无配

有点空,和新上手occi的筒子们一起总结下。这篇内容其实挺有用的,对于新人来说不管哪一方面都是一个难点,如Oracle、unix、c++与occi、shell、makefile、随便挑出一个名词就能够让人学上一阵子了。这篇文章呢,咱就来个彻底的大剖析,目的是连通oracle并进行C++的应用编程,,并在这个基础上,对我们以后每个名词点的深入学习,提供入门的作用。

首先说一下我的环境,(注:大家的工作环境千差万别,但万变不离其宗,今天着重讲这个宗,所以不必拘泥于环境如何,看了我的操作,希望能使你举一反三,各种环境都能应对自如。)由于公司结构不得不形成如下的工作环境:

本人主机:windows+secureCRT,所以我都是在使用远程

工作主机:unix+oracle(本人是oracle服务器端,其实客户端的问题不大后详细解释。)

数据库服务器:我只知道主机ip、数据库用户名及密码,其他都不知道。应该是大型主机。

这种环境貌似是三方,而实际工作是两方,因为我是用windows+secureCRT远程连接到unix工作机上,在unix上编写c++程序调用occi连接远程数据库服务器。所以描述重心是后两者的工作。至于secureCRT(可以是其他ssh工具)连接到unix则需要unix主机的ip地址、用户名及密码即可。

好了,下面的所有工作都是从登陆unix工作机这一刻开始,目标是在unix上编写一段连接远程oracle数据库的c++代码编译、连接、运行成功。各个击破吧!

第一步:编译、连接、运行C++程序,保证C++环境正确。

判断C++环境正确很简单,写个helloworld.cpp程序。代码如:

  • #include    
  •   
  • main()   
  • {   
  • }  
  • 这段代码要包含区别于c的元素,如using语句、cout等;

    在shell里(sh、bash均可,个人更喜欢bash。)运行编译命令:

    CC -c helloworld.cpp

    (注意此处为大写的CC,小写的cc是编译c语言的)。结果会生成helloworld.o文件,继续运行连接命令:

    CC -o helloworld.o

    结果会默认生成a.out文件,此时当前目录下执行 ./a.out 出现打印的hello world!则为成功了(不要漏掉点和斜杠./),C++的编译环境就这样完成了。放心吧,unix默认都会支持CC的,至于gcc那是linux上的gnu项目开发的unix不一定支持。

    linux

    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

    MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

    Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

    ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

    What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

    MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

    MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

    Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

    MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

    Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

    MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

    MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

    MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

    ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

    MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

    ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Article

    Hot Tools

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    VSCode Windows 64-bit Download

    VSCode Windows 64-bit Download

    A free and powerful IDE editor launched by Microsoft

    SecLists

    SecLists

    SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    Integrate Eclipse with SAP NetWeaver application server.