database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 2123 게시물 읽기
No. 2123
MYSQL 과 C언어 연동 할려는데.....
작성자
답답이
작성일
2000-06-16 11:30
조회수
3,225

안녕하세요~~^^

바쁘신데 자꾸질문을 드려 죄송합니다!

울트라 슈퍼 초보라 이렇게 답답한질문들을 하오니 부디

굽어 살펴주시옵서예!

C언어로 MYSQL을 연동할려고 다음과같이

 

gcc test.c -o test -lnsl -I/usr/local/mysql/include/mysql

-L/usr/local/mysql/lib/mysql -lmysqlclient

 

C파일을 컴파일하니 아무런 에러문이 없이 컴파일이 되더라구요!

근데 생성된 TEST*실행파일을 실행하니 아무런현상도

일어나지 않고 바로 다음 프롬프트로 넘어가더라구요!

~># test 엔터

~>#

이렇게 되는 이유가 뭔가요? 제가 C파일을 잘못 짠건가요~아님 데이터베이스문제인가요?

아님 다른 환경설정을 해주어야 하는건가요?(다른일반 C파일은 실행이되더라구요!)

 

설명에 도움이 될까쉽어서 데이터베이스 생성 과정과 C소스를 아래에 올립니다!

도움기다리겠습니다! 감사합니다~~~꾸벅^^

 

mysql>show databases;

+-----------+

| Databases |

+-----------+

| mysql |

| test |

+-----------+

 

mysql>use test

 

mysql>show tables;

+--------+

| Tables |

+--------+

| member | // member는 미리만들어 놓았읍니다

+--------+

 

mysql>desc member;

+------+--------------+-------+---------+--------------+

|Field | Type Null |Key |Default |Extra |

+------------------------------------------------------+

|id | int(11) |PRI |0 |auto_increment|

+------------------------------------------------------+

|name | varchar(20) |YES |NULL | |

+------------------------------------------------------+

|title | varchar(30) |YES |NULL | |

+------+--------------+-------+---------+--------------+

 

mysql>select * from member;

+-----+--------+------+

| id | name | title|

+---------------------+

| 1 | lee | good |

+---------------------+

| 2 | sun | very |

+-----+--------+------+

 

 

이상이 데이터베이스이구요 아래는 test.c의 내용입니다.

 

#include<sys/time.h>

 

#include<stdio.h>

 

#include</usr/include/mysql/mysql.h>

 

 

 

int main(char **args){

 

MYSQL_RES *result;

 

MYSQL_ROW row;

 

MYSQL *connection,mysql;

 

int state;

 

mysql_init(&mysql);

 

connection=mysql_real_connect(&mysql,"localhost","","","test",0,"",0);

 

if(connection==NULL){

 

printf(mysql_error(&mysql));

 

printf("mysql unconnect Fail");

 

return 1;

 

}

 

state=mysql_query(connection,"SELECT name,title FROM member");

 

if(state!=0){

 

printf(mysql_error(connection));

 

printf("mysql connection OK");

 

return 1;

 

}

 

result=mysql_store_result(connection);

 

printf("rows : %d

",mysql_num_rows(result));

 

while((row=mysql_fetch_row(result))!=NULL){

 

printf("name: %s, title: %s

", (row[0] ? row[0] : "NULL"),(row[1] ? row[1] : "NULL"));

 

}

 

mysql_free_result(result);

 

mysql_close(connection);

 

printf("Done.

");

 

}

[Top]
No.
제목
작성자
작성일
조회
2130근데 mysql이 느린가요..
kang
2000-06-16
3133
2135┕>Re: 근데 mysql이 느린가요..
서지훈
2000-06-16 17:31:20
3528
2138 ┕># Re: Re: 근데 mysql이 느린가요.. -&gt; 몇가지 보충
문태준
2000-06-16 20:20:23
3508
2128mysql설치는 root만 가능한가요..
kang
2000-06-16
2927
2134┕>Re: mysql설치는 root만 가능한가요..
서지훈
2000-06-16 17:26:17
3337
2125[질문] linux에서 C API가 사용 가능한지요????
서지훈
2000-06-16
3230
2127┕>Re: [질문] linux에서 C API가 사용 가능한지요????
정재익
2000-06-16 15:50:35
3610
2133 ┕>Re: Re: [질문] linux에서 C API가 사용 가능한지요????
서지훈
2000-06-16 17:19:08
3677
2123MYSQL 과 C언어 연동 할려는데.....
답답이
2000-06-16
3225
2145┕>Re: MYSQL 과 C언어 연동 할려는데.....
외계인
2000-06-17 12:04:18
3594
2184┕>Re: 초기화가 잘못....
이종상
2000-06-20 13:37:42
3565
2121# show processlist 에서...
boky
2000-06-16
3232
2119Warning: 0 is not a MySQL link index in /home/httpd/html/reserve/index.php3 on line 45
윤수진
2000-06-16
3462
2122┕>Re: Warning: 0 is not a MySQL link index in /home/httpd/html/reserve/index.php3 on line 45
박승홍
2000-06-16 10:58:24
3460
2126 ┕>Re: Re: Warning: 0 is not a MySQL link index in /home/httpd/html/reserve/index.php3 on line 45
윤수진
2000-06-16 15:49:46
3763
2132  ┕>Re: Re: Re: Warning: 0 is not a MySQL link index in /home/httpd/html/reserve/index.php3 on line 45
dskim
2000-06-16 17:14:41
3706
2116php가 아파치 루트디렉토리이외에서 실행이 안되는지요???
리눅서
2000-06-16
2973
2118┕>Re: [불꽃남자] 물론 됩지요...
iskraman
2000-06-16 09:35:13
5933
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다