在CentoOS中安装g++ 并连接Oracle数据库
1、安装运行环境
# yum install gcc-c++
备注:此时会将gcc-c++和libstdc++-devel都安装上。
2、查看g++是否安装成功
[root@MyRHEL 桌面]# g++ -v
使用内建 specs。
目标:x86_64-RedHat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)
3、测试
(1)测试C语言程序testc.c
#include<stdio.h>
int main()
{
printf("Hello C!\n");
return 0;
}
运行:
# gcc testc.c -o testc
# ./testc
(2)测试C++程序test.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Come up and C++ me some time.";
cout << endl;
cout << "You won't regret it!" << endl;
return 10;
}
运行:
# g++ -o test1 test.cpp
# ./test1
4 安装OracleClient
主要安装oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm和oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm。
# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
# rpm –ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
5 配置
(1)配置ld.so.conf文件,填入如下内容:
# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/lib/oracle/11.2/client64/lib
(2)配置/etc/hosts文件(此处填入Linux系统主机的IP地址和主机名称),填入如下内容:
# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.48.128 MyRHEL
6 测试与Oracle数据库连接
(1)建立一个connclient.cpp文件,输入如下内容:
[root@MyRHEL test]# vi connclient.cpp
#include<iostream>
#include<string>
#include<occi.h>
using namespace std;
using namespace oracle::occi;
int main()
{
Environment *env;
Connection *conn;
Statement *stmt;
string struser("scott");
string strpwd("Orcl0991");
string strconn_string("10.208.17.206:1521/xe");
env = Environment::createEnvironment(Environment::OBJECT);
conn = env->createConnection(struser, strpwd, strconn_string);
if(NULL!= conn)
cout <<"conn success"<< endl;
else
cout <<"conn failed"<<endl;
string strsql("select deptno,dname from dept");
stmt = conn->createStatement(strsql);
ResultSet *rset = stmt->executeQuery();
while(rset->next()){
int deptno = rset->getInt(1);
string dname = rset->getString(2);
cout<<"deptno="<<deptno<<",dname="<<dname<<endl;
}
stmt->closeResultSet(rset);
conn->terminateStatement(stmt);
env->terminateConnection(conn);
Environment::terminateEnvironment(env);
return0;
}
(2)编译运行:
[root@MyRHEL test]# g++ -o connclient connclient.cpp -L /usr/lib/oracle/11.2/client64/lib -I /usr/include/oracle/11.2/client64/ -locci -lclntsh /usr/lib64/libstdc++.so.6
[root@MyRHEL test]# ./connclient
conn success
deptno=10,dname=ACCOUNTING
deptno=20,dname=RESEARCH
deptno=30,dname=SALES
deptno=40,dname=OPERATIONS
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
在CentoOS中安装g++ 并连接Oracle数据库的更多相关文章
- Java中通过JDBC远程连接Oracle数据库
通过jdbc连接数据库,拢共分三步: 第一步:下载一个JDBC的驱动,然后把jar包扔到项目里并add to build path: 第二步:去本地oracle文件夹下找到“TNSNAMES.ORA” ...
- python 3.x 安装问题及连接oracle数据库
最近有用到python去处理一些问题,发现现在3已出来,遂用直接下3.7使用 发现问题还是有一点的 1. pip 会出现ssl问题 Could not install packages due to ...
- 在PYTHON中,用cx_Oracle连接ORACLE数据库简单示例
一,在安装的时候,参数有点不一样: python setup.py build install 二,连接数据库,有两种方式,DSN和TNSNAMES方式: #dsn = orcl.makedsn(se ...
- Windows server2008 搭建ASP接口訪问连接oracle数据库全过程记录
真的是太不easy了,曾经的时候在window server 2003上面搭建了一套asp+oracle的接口系统.就费了好大的劲儿,事实上那会迷迷瞪瞪的也不知道怎么的就弄好了,也懒得管了.OK,从昨 ...
- [原创]安装Oracle 11gR2,以及如何在win8下使用plsql develper连接Oracle数据库 ,在这里和大家分享下
一,关于win8下安装Oracle 11gR2 1.我下载的是Oracle_11gR2_win64.其中有两个包: 注意:在解压了之后将:win64_11gR2_database_2of2\datab ...
- 通过使用精简客户端,且不需要安装的客户端,配合PLSQL连接oracle数据库
通过使用精简客户端,且不需要安装的客户端,配合PLSQL连接oracle数据库. 首先下载安装包在Oralce官方网站上下载Oracle Instantclient Basic package.地址如 ...
- .net远程连接oracle数据库不用安装oracle客户端
asp.net远程连接oracle数据库不用安装oracle客户端的方法下面是asp.net连接远程Oracle数据库服务器步骤: 1.asp.net连接oracle服务器需要添加Sytem.Data ...
- .net远程连接oracle数据库不用安装oracle客户端的方法
.net远程连接oracle数据库不用安装oracle客户端的方法步骤: 1.添加Sytem.Data.OracleClient命名空间. 2.连接时需要ConnectionString字符串,出现在 ...
- 无需安装Oracle Client连接Oracle数据库
介绍 当我们采用 ODP.NET 检索Oracle 数据库的时候,Oracle客户端是必须安装.假如当时电脑上没有安装Oracle客户端,就不能这么用了,这时候Oracle.ManagedDataAc ...
随机推荐
- 怎么用C#获取Scenario step在specflow里
公司最近在用specflow 这种BDD的模式,但PM还是想把case再存进TestManager里面一份儿一遍后期集成TestManager 自动runcase用.所以我们需要获取每个scenari ...
- csv 导入到 access中去
Csv中有500万数据,导入到Access中去,每6万条数据为1Table 先是参照着http://support.microsoft.com/kb/257819/zh-cn来写 1.找不到可安装的 ...
- [c#]asp.net开发微信公众平台(7)前6篇的整体框架demo源码
这里给出的demo是具备整体框架的微信公众平台源码, 所谓demo就是拿过去就可以直接演示使用的东西, 当然不会具备非常详细的具体到业务层面.数据层面的东西, 每个人都可以在此基础上自由发挥, 只 ...
- shell获取文件行数
获取文件行数: echo `cat $file | wc -l` 获取文件中不重复的行数(去重后) echo `awk '{$1="";print $0;}' $file_tel ...
- Oracle 11g XML java连接
在网上找了好多教程 走好好多弯路 现在从头总结下 oralce11g 可以直接用xmltype节点存储xml文件 简单来说就是直接存一个文件进去 首先安装oracle11g 网上教程非常多 然后进Ne ...
- Oracle ACL (Access Control List)详解
在Oracle11g中,Oracle在安全方面有了很多的改进,而在网络权限控制方面,也有一个新的概念提出来,叫做ACL(Access Control List), 这是一种细粒度的权限控制.在ACL之 ...
- C# 前台线程与后台线程区别
using System; using System.Drawing; using System.Windows.Forms; using System.Threading; namespace Wi ...
- FANTASY:In which way do you think the world will end?
In which way do you think the world will end? The moment you are reading my essay, you are somehow c ...
- osg复制多个相同物体修改材质属性问题
转自http://www.cnblogs.com/ylwn817/articles/2153982.html 当通过osg复制多个相同物体时候,修改复制过来的某个物体材质属性时候,假设我们物体透明度, ...
- uva 280 - Vertex
#include <iostream> #include <cstdio> using namespace std; #include <vector> #defi ...