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
운영게시판
최근게시물
DB2 Q&A 225 게시물 읽기
No. 225
Re: UNIX 용 DB2 사용해보신분 부탁좀 드립니다.
작성자
진의근(ekjin)
작성일
2001-12-07 10:38
조회수
23,052

Linux에서 ODBC 연결을 하려면

ibm site에 유용한 메뉴얼이 있습니다...

저도 그걸로 ODBC연결을 했습니다...

http://www-903.ibm.com/kr/techinfo/db2/에서

DB2 연동을 위한 PHP 웹 프로그래밍 file을 받아 보시면 됩니다.

그럼...

 

 

-- 김재룡 님이 쓰신 글:

>> UNIX용 DB2을 사용해보신분은 부디 끝까지 읽으시고 아시는대로 답글좀

>> 남겨 주셨으면 합니다. 전 아무리 봐도 도대체 뭔 소린지를 모르겠습니다.

>> 서점에서도 UNIX용 DB2책은 보이지가 않더군요.

>>

>> 저희 AS/400에 있는 컴터로 ODBC 연결을 하려 하는데... 잘 안되는군요.

>>

>> <br>

>> 한국 ibm 사이트에 있는 문서는 아주 많은것을 설정하도록? 되어 있더군요.<br>

>> 이것 하다가 말았습니다. 웹서버을 죽어야 하고...<br>

>> 여기저기 스크립트을 포함 시켜야 하고...<br>

>> 된다는 보장도 없고...<br>

>> <br>

>> 그래서 전에 찾았던 영문 문서에 보니 다음과 같이 간단하게? 되어 있습니다.<br>

>> 이것좀 설명해 주시면 고맙겠습니다.<br>

>> 영어 보다도 제가 유닉스 계열의 db2을 사용해 보지 않아서 무슨 말인지을<br>

>> 모르겠습니다.<br>

>> <br>

>> 우선은 리눅스에서 db2을 설치 해야 하는가 봅니다.<br>

>> 제가 설치한것은 90일 트라이얼 버젼 7.2 인데... 7.1을 기준으로 나와서<br>

>> 틀린 명령이 있는지는 모르겠습니다. 버젼이 약간 변경되어 틀릴거라 생각이<br>

>> 들지는 않지만 mysql> 상태처럼 db2는 어떤 명령을 내려야 하는지<br>

>> 도무지 알수가 없군요. 제가 서점에 가서 책 보면 될것 같지만 급해서 ....<br>

>> <br>

>> <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/5613/fid/12" target=nlink>http://www.faqts.com/knowledge_base/view.phtml/aid/5613/fid/12</a><br>

>> <br>

>> AS/400<br>

>> Connection from a Linux Box to AS/400 DB2<br>

>> Connection from a Linux Box to IBM DB2 Mainframes<br>

>> Sep 21st, 2000 13:04<br>

>> <br>

>> Remo Ronchitelli<br>

>> <br>

>> <br>

>> <br>

>> <br>

>> <br>

>> The connection from a Linux Web Server<br>

>> equipped with Apache and PHP 4 <br>

>> to an IBM AS/400 (OS400 and DB2/400)<br>

>> system is possible and works fine.<br>

>> The same connection works with IBM<br>

>> mainframes equipped with OS/390,<br>

>> MVS/ESA, VM/ESA, VSE/ESA and IBM DB2.<br>

>> The only strict requirement is the<br>

>> version of OS400 operating system:<br>

>> it must be V4R2 with native TCP/IP<br>

>> support.<br>

>> The following is the hierarchical<br>

>> list of Software Layers used in the test.<br>

>> ++Linux RedHat 6.1 <br>

>> ------(Korn Shell pdksh rpm package required)<br>

>> ++Apache Web Server 1.3.12<br>

>> ++PHP 4.0.2 statically linked to Apache<br>

>> ------ with-ibm-db2 option enabled<br>

>> ++IBM DB2Connect Personal Edition for Linux<br>

>> ------ V7.1 free from somewhere in ibm.com<br>

>> The IBM DB2 UDB DB2Connect Personal Edition<br>

>> installation is performed via Korn shell script<br>

>> "db2setup". Use all the features you can select,<br>

>> and installl:<br>

>> DB2 Administration Client<br>

>> DB2 Connect Personal Edition<br>

>> Db2 Application Development Client<br>

>> The DB2 instance created on Linux is:<br>

>> "db2inst1" and password "ibmdb2" (defaulted).<br>

>> After this you can install PHP 4<br>

>> --with-ibm-db2 option enabled.<br>

>> You get some weak compilation warnings<br>

>> but don't worry (it would be better they missed).<br>

>> For PHP it looks exactly like you had<br>

>> installed IBM DB2 UDB Personal Edition<br>

>> (the whole DB2 engine "without" DB2Connect).<br>

>> On the AS/400 side you have to start<br>

>> "drda" tcp servers at port "446" (defaulted).<br>

>> On the AS/400 side you need also<br>

>> authorized userid and password.<br>

>> Along with IBM DB2Connect you get full<br>

>> HTML documentation (useful and clear).<br>

>> Now return to Linux:<br>

>> login as "db2inst1" password "ibmdb2" and<br>

>> type: "db2" (DB2 command line processor).<br>

>> This is the necessary to inform DB2Connect<br>

>> about the reality of DB2400 DataBase on the<br>

>> AS/400. Thatis:<br>

>> 1. 'catalog tcpip node YOUR_FREE_NODE_NAME<br>

>> remote TCP_IP_ADDRESS_OF_AS400<br>

>> server 446<br>

>> remote_instance AS400_SYSTEM_NAME<br>

>> system YOUR_FREE_SYSTEM_NAME<br>

>> ostype OS400'<br>

>> (446 is the default port number of drda server)<br>

>> (ostype must be "OS400") <br>

>> 2. 'catalog dcs database YOUR_DB_NAME <br>

>> as DB2400_REAL_NAME'<br>

>> (DB400_REAL_NAME is the cataloged name of<br>

>> DB2 system in the AS/400 or the RDBNAME of AS/400)<br>

>> 3. 'catalog database YOUR_DB_NAME as PHP_DB_NAME<br>

>> at node YOUR_FREE_NODE_NAME<br>

>> authentication DCS'<br>

>> (if you choose authentication "SERVER" it doesn't work).<br>

>> 4. 'connect to PHP_DB_NAME<br>

>> user AS400_USERID<br>

>> using AS400_PASSWORD'<br>

>> 5. (Caution to escape double quotes!) <br>

>> 'bind \"/usr/IBMdb2/V7.1/bnd/@ddcs400.lst <br>

>> BLOCKING ALL SQLERROR CONTINUE<br>

>> MESSAGES DDCS400.MGS GRANT PUBLIC\" ' <br>

>> 6. 'connect reset'<br>

>> 7. 'terminate'<br>

>> (quit from DB2 Command Line Processor).<br>

>> <br>

>> You can now access DB2/400 from a PHP script<br>

>> enabled with:<br>

>> 'putenv<br>

>> ("LD_LIBRARY_PATH=/home/db2inst1/sqqlib/lib:$LD_LIBRARY_PATH"); ' <br>

>> 'putenv ("DB2INSTANCE=db2inst1"); ' <br>

>> 'odbc_connect(PHP_DB_NAME, AS400_USERID, AS400_PASSWORD);'<br>

>> <br>

>> Warning: The Table name referenced in your PHP script<br>

>> must be qualified with the "collection" or "library" name<br>

>> of AS/400 DB2 system. Example:<br>

>> "SELECT * FROM AS400LIB.TABLE"<br>

>> The default would be <br>

>> "SELECT * FROM DB2INST1.TABLE" (surely wrong).<br>

>> <br>

>> Take your fun with AS/400 or Mainframe system!<br>

>> Remo Ronchitelli<br>

>> <a href="/Mail-bin/send_mail.form.cgi?TO=sangiorgionet@netscape.net">sangiorgionet@netscape.net</a><br>

>> <br>

>> <br>

>> 그리고 다른곳에서 또 비슷한 방법으로 연결 하는 방법이 소개 되어 있습니다.<br>

>> <br>

>> <a href="http://www.phpbuilder.com/forum/archives/5/2000/12/4/5587" target=nlink>http://www.phpbuilder.com/forum/archives/5/2000/12/4/5587</a><br>

>> <br>

>> Author: Derek Piper<br>

>> Date: 2001-01-25 09:04:29<br>

>> Subject: RE: AS/400 DB2 Queries via PHP<br>

>> <br>

>> Umm.. okay. I might not be good at explaining this but I'll try. <br>

>> <br>

>> The information I found out came from a nice guy called Remo whom I found had written these steps in an email. We emailed back and forth for a while about it and I had success with reading data off the AS/400. Unfortunately we both had the same problem in being unable to insert/update/delete records so I don't know if that will ever get sorted out. Still, you can read data off the AS/400 using SELECT statements. <br>

>> <br>

>> Okay.. so, my notes that I made about it. <br>

>> <br>

>> ------ <br>

>> IBM AS/400 DB2 Connect to Linux Apache/PHP <br>

>> <br>

>> Install DB2 Connect Personal (or Enterprise) Edition on Linux WWW machine. <br>

>> <br>

>> Compile PHP with DB2 Support (for appropriate version - the example given is for version 7.1). <br>

>> <br>

>> Add this option to your PHP compile options <br>

>> <br>

>> --with-ibm-db2=/usr/IBMdb2/7.1/include/ <br>

>> <br>

>> Create DB2 Instance on Linux machine. Use the 'db2setup' command in the 'install' subdirectory of the DB2 Connect installation. Set up the account but not with the defaults, pick an original password at least. <br>

>> e.g. <br>

>> user db2as400 <br>

>> password ????? <br>

>> <br>

>> Set up a user on the AS/400 and keep username and password for later to use in place of [as400user] and [as400pass]. Set that user's CCSID to '037' (for USA), do not leave it at 65535 (possibly system default). Make sure permissions are correct for any tables that need to be read or written to. <br>

>> <br>

>> Configure DB2 Instance by logging into Linux machine as DB2 user and password (as defined above) (or by su'ing from root to db2 account). Use command 'db2' to enter command line processor. From there, type (on one line per statement): <br>

>> <br>

>> (Items in [] are the user definable settings - don't include the [], just make up different names that are unique) <br>

>> <br>

>> catalog tcpip node [localName] remote 192.168.4.4 server 446 remote instance [youras400] system www ostype OS400 <br>

>> <br>

>> catalog dcs database [as400DB] as [youras400] <br>

>> or <br>

>> catalog dcs database [as400DB] as [youras400] parms ",,,,,,,,BIDI=037" <br>

>> <br>

>> catalog database [as400DB] as [DSN] at node [localName] authentication DCS <br>

>> <br>

>> connect to [DSN] user [as400user] using [as400pass] <br>

>> <br>

>> bind /usr/IBMdb2/V7.1/bnd/@ddcs400.lst BLOCKING ALL SQLERROR CONTINUE MESSAGES DDCS400.MGS GRANT PUBLIC <br>

>> <br>

>> connect reset <br>

>> <br>

>> terminate <br>

>> <br>

>> Example PHP and SQL code: <br>

>> <br>

>> $sql = "SELECT * FROM AS400LIBRARY.AS400FILE"; <br>

>> <br>

>> if ($conn_id = odbc_connect("[DSN]", "[as400user]", "[as400pass]")) { <br>

>> if ($result=odbc_do($conn_id, $sql)) { <br>

>> odbc_result_all($result); <br>

>> odbc_free_result($result); <br>

>> } else { <br>

>> echo "cannot execute '$sql'<br>

>> "; <br>

>> } <br>

>> odbc_close($conn_id); <br>

>> } else { <br>

>> echo "can not connect to DSN: $dsn<br>

>> "; <br>

>> } <br>

>> <br>

>> You should then be able to retrieve data from the AS/400 using normal SQL SELECT commands. Note that the library that the AS/400 file is in has to be in every statement. <br>

>> <br>

>> <br>

>> 제가 하는 방법은 웹서버을 죽일수 없으니 PHP을 쉘에서 실행 시키는 방법으로<br>

>> PHP만 컴파일을 시키고 있습니다.<br>

>> 위와 같은 방법으로 했는데.. 경고가 뜨더군요.<br>

>> <br>

>> QL error: [IBM][CLI Driver] SQL1001N "xxx.xxx.xxx.xxx"은(는) 유효한 데이터베이스 이름이 아닙니다. SQLSTATE=2E000, SQL state S1501 in SQLConnect in<br>

>> <br>

>> 위는 분명 db2에서 DSN 에 관한것을 설정해 주지 않아서 나오는것 같은데...<br>

>> db2의 데몬을 띄우는 방법과 죽이는 법...<br>

>> 그리고 쉘에서 db2을 접속하는 방법 ..<br>

>> 등 .. 아주 기본적인것 ... 위에 영문으로 되어 있는것 사용 할수 있을 정도의<br>

>> 간단한것만 설명해 주셨으면 고맙겠습니다.<br>

>> <br>

>> 그럼 미리 감사 드립니다.<br>

>> <br>

>> <br>

[Top]
No.
제목
작성자
작성일
조회
238[질문]SNA 방식의 host DB2 연결 (ODBC)
김성
2001-12-26
10479
240┕>Re: [질문]SNA 방식의 host DB2 연결 (ODBC)
이전건
2002-01-03 15:06:31
11055
226SELECT INTO에 관하여... [1]
파르
2001-12-07
11769
224[질문] 테이블 데이터 입력이 안됩니다.????
정규성
2001-12-07
10162
223UNIX 용 DB2 사용해보신분 부탁좀 드립니다.
김재룡
2001-12-06
7821
225┕>Re: UNIX 용 DB2 사용해보신분 부탁좀 드립니다.
진의근
2001-12-07 10:38:58
23052
215사용자계정으로 db2연결 할 수없나요?
박은선
2001-11-30
10656
217┕>Re: 사용자계정으로 db2연결 할 수없나요?
이전건
2001-12-02 00:12:13
12080
202[질문] DB2 데몬에 대하여...??? [1]
정규성
2001-11-28
11207
201[무지초보]CDpc.db2 라는 파일을 읽고 싶습니다.
임영진
2001-11-26
11149
220┕>Re: [무지초보]CDpc.db2 라는 파일을 읽고 싶습니다.
이전건
2001-12-02 00:30:08
11648
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다