linuxoraclec語言
A. 怎麼在linux環境下通過c/c++語言連接oracle資料庫
推薦你使用pc語言,用這個編寫代碼很容易對資料庫oracle進行操作.各種操作都非常簡單.
例如:
EXEC sql CONNECT :UserName IDENTIFIED BY :PassWord using :ServerName;
這樣一個簡單語句就可以實現連接資料庫.
EXEC SQL CALL insert_data_sms(:spnumber,:usernumber,:content,:flag,:priority,:spnode,:sequenid_sp,:iresult);
EXEC SQL COMMIT;/*提交事務*/
可調用存儲過程.
你可以找找這方便的書看看
B. linux下c++遠程連接oracle資料庫
你說的復合結構應該是結構體吧。若是舉個例子給你看看
/*
* sample2.pc
*
* This program connects to ORACLE, declares and opens a cursor,
* fetches the names, salaries, and commissions of all
* salespeople, displays the results, then closes the cursor.
*/
#include <stdio.h>
#include <sqlca.h>
#define UNAME_LEN 20
#define PWD_LEN 40
/*
* Use the precompiler typedef』ing capability to create
* null-terminated strings for the authentication host
* variables. (This isn』t really necessary--plain char *』s
* does work as well. This is just for illustration.)
*/
typedef char asciiz[PWD_LEN];
EXEC SQL TYPE asciiz IS STRING(PWD_LEN) REFERENCE;
asciiz username;
asciiz password;
struct emp_info
{
asciiz emp_name;
float salary;
float commission;
};
/* Declare function to handle unrecoverable errors. */
void sql_error();
main()
{
struct emp_info *emp_rec_ptr;
/* Allocate memory for emp_info struct. */
if ((emp_rec_ptr =
(struct emp_info *) malloc(sizeof(struct emp_info))) == 0)
{
fprintf(stderr, "Memory allocation error. ");
exit(1);
}
/* Connect to ORACLE. */
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf(" Connected to ORACLE as user: %s ", username);
/* Declare the cursor. All static SQL explicit cursors
* contain SELECT commands. 』salespeople』 is a SQL identifier,
* not a (C) host variable.
*/
EXEC SQL DECLARE salespeople CURSOR FOR
SELECT ENAME, SAL, COMM FROM EMP WHERE JOB LIKE 』SALES%』;
/* Open the cursor. */
EXEC SQL OPEN salespeople;
/* Get ready to print results. */
printf(" The company』s salespeople are-- ");
printf("Salesperson Salary Commission ");
printf("----------- ------ ---------- ");
/* Loop, fetching all salesperson』s statistics.
* Cause the program to break the loop when no more
* data can be retrieved on the cursor.
*/
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
EXEC SQL FETCH salespeople INTO :emp_rec_ptr;
printf("%-11s%9.2f%13.2f ", emp_rec_ptr->emp_name,emp_rec_ptr->salary, emp_rec_ptr->commission);
}
/* Close the cursor. */
EXEC SQL CLOSE salespeople;
printf(" Arrivederci. ");
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void sql_error(msg) char *msg;
{
char err_msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf(" %s ", msg);
/* Call sqlglm() to get the complete text of the
* error message.
*/
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s ", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
C. 關於linux方面找工作
你現在已經學習了linux的一些通用招式。我覺得你找一個系統管理員的工作應該問題不大。
如果要做開發工作,你就面臨選擇。你可以根據興趣或者行業前景,要知道linux能做的事情很多,比如oracle的資料庫,Java, Apache等都是最先在linux下實現的。C語言也是隨著Unix誕生的。還有現在很火的移動終端android, 其內核還是linux。
所以,你要選擇一個方向學習,比如你學習資料庫,那可以用做金融,游戲,科研等;你學習內核,那你可以做驅動。
建議你接受zkx1217童鞋的建議。先投簡歷!!!!
D. LINUX C/C++用什麼連接oracle資料庫啊解決辦法
在Windows的控制面板中,查找ODBC數據源,配置一個能夠連接Oracle的數據源,並測試能夠成功連接。然後在VS中連接這個數據源即可。
E. 我想在linux下用C語言連接遠程oracle,可以不裝客戶端而用代碼實現連接並操作嗎如果可以,怎麼連
必須使用orcale資料庫提供的客戶端開發庫中的函數來和oracle資料庫伺服器來進行通訊。