Connecting to oracle database using C programming - occi

I am trying to connect to oracle database using C code. Is it possible to use OCCI in the code? If yes please help me with some examples, please note it has to be C code.
If not what are the other options to connect to database using C.

OCCI is short for 'Oracle C++ Call Interface' and is targeted to C++ applications. If your application is going to be purely in C, then you should use OCI (Oracle Call Interface) instead as that is Oracle's call interface for applications written in C.
See the Programmer's guide for help and examples.

Related

Which are suitable local database (easy to handle with C++) for a small data set

The computer has already been installed ORACLE. But I didn't try ORACLE before, I just use sqlite...So, for now I want to create a database locally, and just insert one table. I want to use a test C++ program to read and write in this database. Is there something useful for using API about this? BTW, in the computer I saw SQL plus and SQL developer, but I didn't find the DBCA, which I know can be used to create table...help me, thanks a lot!!
BTW, my supervisor wants to me to test different kinds of database, which will be written in my report. So I want to test different kinds of databases, for the data is quite small, just 100 lines in a table is enough, but it will be applied in a big program, so I need to try different kinds of database locally, and not difficult for me to use C++ API...Because I just know little about database. I need some suggestions, thank a lot!
While I wouldn't recommend Oracle for handling small data sets, I do have a pointer to C++ API documentation.
http://www.oracle.com/pls/db112/portal.portal_db?selected=5&frame=
... and scroll to the bottom of the page for links to further information.
There's a choice of either using C++ with Oracle OCI API, or using C++ with Oracle Pro*C precompiler. The precompiler actually does produce code that uses the OCI API.
I have done some work with the Pro*C precompiler (using C as the implementation language, though, not C++), and it wasn't too bad. OCI tends to be quite low-level, but apparently writing direct OCI code has its uses, too.

Connect to oracle database with C++

I am looking for a way to connect to an remote oracle database and read some data from table within a c++ console application.
Can some one give me some hints.
Thnx.
soci, http://soci.sourceforge.net, is a reasonably modern C++ interface that uses the Oracle call interface. And can also connect to other databases ...
The official Oracle website proposes several resources. Amongst others:
Oracle C++ Call Interface
Develop C and C++ Applications with Oracle Database 11g Using OCI
Just google, there are really plenty of tutorials around.
You can either use the Oracle C++ Call Interface (native API) or the Open DataBase Connectivity API. If you want a more high-level wrapper, there are some more convenient interfaces in libraries such as Qt.
Unless it's study purpose or strict requirement with ORACLE DB, I'd suggest you to work with generic classes/services provided with various Microsoft Framework.
Data Access Programming
MFC Database classes
ATL Database classes
Of course ORCACLE C++ IF is also available.
You can use OCCI: http://www.oracle.com/technetwork/database/features/oci/index-090820.html
or OCI: http://www.oracle.com/technetwork/database/features/oci/index.html
or one of many other APIs available.. It really depends on the type of thing you're going to use it for.. You should find a lot of information about the pros/cons of the various APIs through google..
You can try: CODBC. It is an API for Pro*C. Pro*C is a very decent way to connect Oracle and C++.
Currently (2021) actively developed is also OCILIB, I was able to setup the test example in short time.

Is implementing fastcgi using C++ feasible?

Webserver(Apache2/ngnix) + PHP(fastcgi) + MySQL
The above combination is common.
How about using C++ instead of PHP? As there is a C++ driver for MySQL, so database connection won't be a big problem. But how to implement the fastcgi in C++? Is looking at php-fpm a good starting point?
Anyone with similar experience please share.
Thanks.
Perhaps it might be easier to write a C++ extension for PHP that has all your code in it. That way, you can use the PHP fastcgi engine but your entire webapp bypasses PHP (the language and the compiler) entirely.
"Ablaze is a FastCGI web application development framework for C++ designed for efficiency, high throughput and lightning response time."
Hi this http://cplusplus-soup.com/2009/12/28/c-instead-of-php-for-the-web/ can be usefull

C++ Program communicating with MySQL Database

Does anyone know of a simple way for a C++ program to communicate directly with a MySQL database? I have looked at MySQL++ and found it to be very confusing. If anyone knows of a very simple way of doing this, please let me know.
Thanks
P.S. I am developing on a Windows machine. PHP and MySQL web web application setup. C++ setup to talk to the serial port. Thus why I need a way for C++ to talk to the MySQL database directly.
There are quite a few database API wrappers but my favourite - and the one I recommend - is the SOCI library. Much nicer syntax than using the raw C API.
The 'motivating' example from the SOCI website:
int id = ...;
string name;
int salary;
sql << "select name, salary from persons where id = " << id, into(name), into(salary);
The C MySQL API is just like using the PHP MySQL extension and so should be pretty familiar. If you are comfortable with C, I'd recommend that (and you don't mind mixing C in your C++).
Use the C API:
http://dev.mysql.com/doc/refman/5.0/en/c.html
MySQL has a beta release of MySQL Connector C++ that can be found Here. It's a connector written in C++ but modeled after Java's JDBC connectors. If you've used JDBC at all, this will feel almost identical. It's also cross platform and can be compiled on Linux, Windows, and Mac OS.
I have used MySQL++ with great success. I found it to be everything I was looking for in a MysQL database client library. The examples they provide are great, see here for a simple one.
If you know C++, it is much easier to use than the C library. It works great with Windows.
Use SQLAPI++ - it does SQL Server and more.
http://www.sqlapi.com/
MySQL Connector/C++ is a C++ implementation of JDBC 4.0
The reference customers who use MySQL Connector/C++ are:
- OpenOffice
- MySQL Workbench
Learn more: http://forums.mysql.com/read.php?167,221298
Are you sure that the C++ program needs to interact directly with the MySQL database?
I would suggest having the C++ program communicate with the web server using simple http requests, and let PHP handle the database. Data can be passed to a server-side PHP script via arguments, and data can be returned in XML format.
Writing: your.server.com/add_data.php?table="info"&data="0xFCBD..."
Reading: your.server.com/get_data.php?table="info"

Is there an easy way to provide a Matlab-based Web App or Web Service?

A colleague and I have spent a few years developing a really cool Matlab application, MDLcompress. Within Matlab, I can type "MDLcompress('filename.txt')" and it will tell me all sorts of really cool stuff about the contents of filename.txt. We'd like to allow other people to use MDLcompress without downloading the code, installing Matlab, etc. Ideally, we'd have a simple web page where they selected a file from their machine, it got uploaded to my workstation (which is already running tomcat for other purposes, if that makes things easier), kicked off a process along the lines of "matlab < MDLcompress.m filename.txt > results.txt" and then displayed results.txt in their browser or showed a link to let them download it.
Trouble is, my Matlab skills far exceed my web skills. Google has 100 generic tutorials, but nothing as simple as I want, at least not specific to Matlab.
Thanks in advance
If you are mostly proficient in MATLAB you can write web application in MATLAB with MATLAB Web Server
Edit:
Matlab Web Server is discontinued, so it is not for you if you use recent version of Matlab. May be this tutorial will help to create CGI module from Matlab code.
A possible way is to compile the matlab code into C,
and then make the C file into an apache module, and use an apache server.
I have no idea how complicated this is, but it may work.
Based on the tags, I assume you're trying to deploy to Tomcat or similar. The most straightforward way to do this is to use MATLAB Builder JA to create a Java wrapper for your code, then use the standard tools to deploy the Java as a web service.
If you can afford to lose some of Matlab's more powerful proprietary features, there are several open-source numerical computation engines that use syntax mostly compatible with that of Matlab. One of the most mature of these is GNU Octave.
There are several examples of online Octave interfaces. Octave Online is a new interface that supports a live prompt and an online editor. I am a member of the team developing Octave Online. You can find more examples of online Octave interfaces on the Octave wiki. The Octave mailing list is a good resource for prior online Octave projects.
We have developed a toolbox called Modelit Webserver Toolbox that should allow you to do this. We use this ourselves to run a Routing algorithm implemented in Matlab for an online route planner (the link is on our website). You can use the toolbox in conjunction with Tomcat and Matlab (2006b and up) or a compiled Matlab executable. The toolbox also provides a mechanism to run several jobs in parallel.