|
- ÁÖÀÇ»çÇ× : ¾Æ·¡ ¹®¼¸¦ ²À ÀÐ¾î º¸½Ã±â ¹Ù¶ø´Ï´Ù. ÇÊÀÚÀÇ °æ¿ì ¾Æ·¡ ¹®¼¸¦ Âü°íÇؼ ¼º°øÇß½À´Ï´Ù.
http://www.phpschool.com/bbs2/inc_view.html?id=6635&code=tnt2&start=0&
mode=&s_que=&field=&operator=&period=&category_id=
target=_blank>http://okjsp.pe.kr/doc/tomcat/tomcat-4.0-doc/class-loader-howto.html
- Âü°í »çÀÌÆ®
http://www.phpschool.com
http://www.okjsp.pe.kr
http://www.kimho.pe.kr
Á¦¸ñ : ¼Ö¶ó¸®½º¿¡ apache+tomcat(jsp)+jdbc 2.0(¿À¶óŬ) ¶Ç´Â jdbc(mysql)»ç¿ëÇϱâ
OS : x86 Solaris 8(10/01)
apache : apache-1.3.24
jdk : 1.3.1
apache-tomcat ¿¬°á ¸ðµâ : mod_webapp.so
DB : oracle 8.1.7,mysql-3.23.49 ( ¿À¶óŬ ¼³Ä¡¿Í mysql¼³Ä¡´Â »ý·«)
1. ¼³Ä¡¿¡ ÇÊ¿äÇÑ ÆÄÀÏ ´Ù¿î·Îµå
apache : http://www.apache.org/dist/httpd/ (apache_1.3.24.tar.gz)
jdk : http://java.sun.com/j2se/1.3/download.html (j2sdk-1_3_1_03-solx86.sh)
jakarta-tomcat(¹ÙÀ̳ʸ®) : http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.3/bin
/ (jakarta-tomcat-4.0.3.tar.gz)
jdbc 2.0(oracle) : ¿À¶óŬÀÌ ¼³Ä¡µÇ¾î ÀÖÀ¸¸é $ORACLE_HOME/jdbc/lib¿¡ ÀÖ½¿(classes12.zip)
Âü°í·Î $ORACLE_HOME/jdbc/Readme.txt ¸¦ ²À Àо½Ã±â ¹Ù¶ø´Ï´Ù.
´Ù¿î·Îµå ¹ÞÀ»¼ö Àִ°÷ :
target=_blank>http://www.hellophp.com
jdbc(mysql) : http://www.mysql.com/downloads/api-jdbc.html (mm.mysql.jdbc-1.2c.tar.gz)
jakarta-tomcat-connectors : http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.3/src
/ (jakarta-tomcat-connectors-4.0.2-01-src.tar.gz)
Âü°í : jakarta-tomcat-connectors´Â ¼Ò½ºÆÄÀϷδ ÄÄÆÄÀÏÀÌ µÇÁø ¾Ê¾Æ CVS¸¦ »ç¿ë
2. jdk ¼³Ä¡
¼Ö¶ó¸®½º¿¡´Â ±âº»ÀûÀ¸·Î jdk 1.2.x¿Í jdk 1.3.x¹öÀüÀÌ ¼³Ä¡µÇ¾î ÀÖ½À´Ï´Ù.
Àִ°ÍÀ» ±×´ë·Î »ç¿ëÇϼŵµ µÇÁö¸¸ ÀúÀÇ °æ¿ì ´Ù¿î¹ÞÀº °ÍÀ» »ç¿ëÇß½À´Ï´Ù.
¾ÐÃà Ç®±â(/usr/local)
# ./j2sdk-1_3_1_03-solx86.sh¿Í °°ÀÌ ÇÏ¸é ¾ÐÃàÀÌ Ç®¸³´Ï´Ù.
# mv j2sdk-1_3_1_03 java
# rm /usr/java(±âÁ¸¿¡ ¼³Ä¡µÈ jdk»èÁ¦, /usr/java1.1¿¡¼ ¸µÅ©µÇ¾î ÀÖ½¿)
# ln -s /usr/local/java /usr/java·Î ¸µÅ©
¼Ö¶ó¸®½º´Â ±âº»ÀûÀ¸·Î º»½©À» »ç¿ëÇÕ´Ï´Ù. ÇÊÀÚÀÇ °æ¿ì ¸®´ª½º¿¡ Àͼ÷Çؼ bash½©À» ¼³Ä¡ »ç¿ëÇÕ´Ï´Ù.
¾Æ·¡ÀÇ ÆÄÀÏÀ» ¿¾î ´ÙÀ½À» Ãß°¡
# vi /root/.bash_profile
JAVA_HOME=/usr/java
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
export JAVA_HOME CLASSPATH
# source /root/.bash_profile
Å×½ºÆ®
# java -version
java version \"1.3.1_03\"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)
À§¿Í °°ÀÌ ³ª¿À¸é ¼º°ø
3. apache ¼³Ä¡
# httpd -l
Compiled-in modules:
http_core.c
mod_so.c <== Áß¿ä(²À ÀÖ¾î¾ß ÇÕ´Ï´Ù.)
À§¿Í °°ÀÌ ³ª¿À¸é ¼³Ä¡¸¦ ¾ÈÇϼŵµ µË´Ï´Ù. ¾Æ´Ï¸é ¾ÆÆÄÄ¡¸¦ µ¿Àû(DSO)À¸·Î ÄÄÆÄÀÏ
´Ù¿î¹ÞÀº apache_1.3.24.tar.gz ÆÄÀÏÀ» ¾ÐÃàÀ» ÇØÁ¦ÇÑ´Ù. ¼³Ä¡¿É¼ÇÀº »ç¿ëÀÚÀÇ È¯°æ¿¡ ¸Â°Ô Ãß°¡..
# ./configure --prefix=/usr/local/apache (¾ÆÆÄÄ¡°¡ ¼³Ä¡µÉ µð·ºÅ丮)
--enable-rule=SHARED_CORE
--enable-module=so
# make ; make install
4. jakarta-tomcat ¹× mysql jdbc ¼³Ä¡
¹ÙÀ̳ʸ® ¹öÀüÀ̱⠶§¹®¿¡ ¾ÐÃàÀ» Ç®°í ȯ°æ ¼³Á¤À» ÇÏ¸é ¼³Ä¡ ³¡
# tar -xvfz jakarta-tomcat-4.0.3.tar.gz
# mv jakarta-tomcat-4.0.3 /usr/local/tomcat
mm.mysql.jdbc-1.2c.tar.gz ÆÄÀÏÀ» ¾ÐÃàÇØÁ¦ ÇÑ´Ù.
# tar -xvzf mm.mysql.jdbc-1.2c.tar.gz
¾ÐÃàÀ» Ç®°í mysql_comp.jar¿Í mysql_uncomp.jar ÆÄÀÏÀ» tomcatµð·ºÅ丮/lib·Î º¹»ç
# cp mysql_comp.jar mysql_uncomp.jar /usr/lcoal/tomcat/lib
5. apache-tomcat ¿¬°á ¸ðµâ ¼³Ä¡(mod_webapp.so)
ÀÓÀÇÀÇ µð·ºÅ丮¸¦ ¸¸µé°í À̵¿
¼Ò½º¸¦ ¹Þ´Â´Ù.
# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
(Logging in to anoncvs@cvs.apache.org)
CVS password: anoncvs
# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout jakarta-tomcat-connectors/webapp
À§¿Í °°ÀÌÇϸé jakarta-tomcat-connectors/webapp¿¡ ¼Ò½º°¡ ÀÖ´Ù
APR (Apache Portable Runtime) sources
# cd ./jakarta-tomcat-connectors/webapp
# cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout apr
# ./support/buildconf.sh
# ./configure --with-apxs=/usr/local/apache/bin/apxs (ÇÊÀÚÀÇ °æ¿ì /usr/local/apache¿¡ ¼³Ä¡)
# make
# pwd
/usr/local/src/jakarta-tomcat-connectors/webapp/apache-1.3
ÀÌ·¸°Ô ÇϽøé apache-1.3¿¡ mod_webapp.so°¡ »ý¼ºµÇ¾î ÀÖ½¿
# cp mod_webapp.so /usr/local/apache/libexec ·Î º¹»ç
6. ¾ÆÆÄÄ¡ ȯ°æ¼³Á¤
httpd.conf¸¦ ¿¾î ´ÙÀ½À» Ãß°¡
LoadModule webapp_module libexec/mod_webapp.so
AddModule mod_webapp.c
WebAppConnection conn warp localhost:8008
WebAppDeploy examples conn /examples
WebAppInfo /webapp-info
7. oracle jdbc 2.0 ¼³Ä¡
ÀÌ°Å ¶§¹®¿¡ »ðÁú ¸¹ÀÌ Çß½À´Ï´Ù.
´Ù½ÃÇѹø http://okjsp.pe.kr/doc/tomcat/tomcat-4.0-doc/class-loader-howto.html ¹®¼¸¦ ²À Àо½Ã±â ¹Ù¶ø´Ï´Ù.
Á¦ÀÏ È®½ÇÇÑ ¹æ¹ýÀº $ORACLE_HOME/jdbc/lib/classes12.zip ÆÄÀÏÀ» ¾ÐÃàÀ» ÇØÁ¦ ÇÕ´Ï´Ù.
±×·³ µÎ°³ÀÇ µð·ºÅ丮°¡ »ý±é´Ï´Ù. ÀÌ°ÍÀ» ´Ù½Ã jarÆÄÀÏ·Î ¾ÐÃàÀ» ÇÕ´Ï´Ù.
# unzip classes12.zip
# ls
javax oracle
# jar cvf classes12.jar javax/ oracle/ ÀÌ·¸°Ô Çϸé classes12.jar ÆÄÀÏ »ý¼º
# cp classes12.jar /usr/local/tomcat/common/lib
ÀÌÁ¦ ¸ðµç ¼³Ä¡´Â ³¡ÀÌ ³µ½À´Ï´Ù. ¸¶Á÷¸·À¸·Î Å×½ºÆ®
8. Å×½ºÆ®
¸Õ¼ tomcat¸¦ ½ÃÀÛÇÑ´Ù.
# /usr/local/tomcat/bin/start.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JAVA_HOME: /usr/java
¾ÆÆÄÄ¡ ½ÃÀÛ
# /usr/local/apache/bin/apachectl start
À¥¿¡¼ È®ÀÎÀ» ÇÑ´Ù.
http://domain:8080/
°í¾çÀÌ ±×¸²ÀÌ ³ª¿À¸é ¼º°ø. ÀÌ·¸°Ô ³ª¿À¸é ¾ÆÆÄÄ¡¿Í ÅèÄÏÀÌ Á¤»óÀûÀ¸·Î ¼³Ä¡µÈ°Í ÀÔ´Ï´Ù.
ÀÌÁ¦ Á¤¸» Áß¿äÇÑ jdbc Å×½ºÆ®
============ mysql jdbc Å×½ºÆ® =============
/usr/local/tomcat/webapps/ROOT¿¡ mysql.jsp¶ó´Â ÆÄÀÏÀ» ¸¸µé°í ´ÙÀ½ ³»¿ëÀ» ÀÔ·ÂÇÑ´Ù.
Âü°í·Î mysqlÀÇ »ç¿ëÀÚ µî·Ï ¹× Å×ÀÌºí »ý¼ºÀº »ý·«ÇÕ´Ï´Ù.
ÇÊÀÚÀÇ °æ¿ì test¶ó´Â DB¸¦ »ý¼ºÇÏ°í test¶ó´Â »ç¿ëÀÚ¿Í test¶ó´Â Æнº¿öµå¸¦ ÀÔ·ÂÇß½À´Ï´Ù.
±×¸®°í test¶ó´Â Å×À̺íÀ» ¸¸µé°í ±×Áß nameÇʵ带 10°³ °¡Á®¿É´Ï´Ù.
<%@ page language=\"java\" import=\"java.sql.*\" contentType=\"text/html;charset=KSC5601\" %>
<%
Class.forName(\"org.gjt.mm.mysql.Driver\");
Connection Conn = DriverManager.getConnection(\"jdbc:mysql://localhost/test\",\"test\",\
"test\");
Statement stmt = Conn.createStatement();
ResultSet rs = stmt.executeQuery(\"select name from test limit 10\");
if (!rs.next()) {
out.println(\"¾Ï°Íµµ ¾ø´Ù\");
} else {
while(rs.next()) {
out.println(rs.getString(1));
}
}
stmt.close();
Conn.close();
%>
¿©±â¿¡¼ DriverManager.getConnection(\"jdbc:mysql://localhost/test\",\"test\",\
"test\")´Â ¾Æ·¡¿Í °°´Ù.
DriverManager.getConnection(\"jdbc:µå¶óÀ̹ö://localhost/DB¸í\",\"DB User\",\"DB Pass\")
À¥¿¡¼ È®ÀÎÀ» ÇÑ´Ù.
http://domain:8080/mysql.jsp
¿©±â¼ ÇÊÀÚÀÇ °æ¿ì À̸§ÀÌ Ãâ·ÂµË´Ï´Ù. \"¾Ï°Íµµ ¾ø´Ù\" ¶óµç°¡ À̸§ÀÌ Ãâ·ÂµÇ¸é ¼º°ø... ÃßÄ«ÃßÄ«
==================================================
============ oracle jdbc Å×½ºÆ® =============
/usr/local/tomcat/webapps/ROOT¿¡ oracle.jsp¶ó´Â ÆÄÀÏÀ» ¸¸µé°í ´ÙÀ½ ³»¿ëÀ» ÀÔ·ÂÇÑ´Ù.
Âü°í·Î oracleÀÇ »ç¿ëÀÚ µî·Ï ¹× Å×ÀÌºí »ý¼ºÀº »ý·«ÇÕ´Ï´Ù.
ÇÊÀÚÀÇ °æ¿ì oracle¶ó´Â DB¸¦ »ý¼ºÇÏ°í scott¶ó´Â »ç¿ëÀÚ¿Í tiger¶ó´Â ±âº»ÀûÀÎ »ç¿ëÀÚ¸¦ »ç¿ëÇß½À´Ï´Ù.
DB »ý¼º½Ã »ç¿ëÀÚ Á¤ÀÇ·Î »ý¼ºÀ» ÇϽøé scott¶ó´Â »ç¿ëÀÚ°¡ »ý¼ºµÇÁö ¾Ê½À´Ï´Ù.
±×¸®°í ¾Æ·¡ BONUSµµ »ç¿ëÀÚ Á¤ÀÇ·Î DB·Î »ý¼ºÀ» ÇÏ½Ã¸é »ý¼ºµÇÁö ¾Ê½À´Ï´Ù.
<%@ page language=\"java\" import=\"java.sql.*\" contentType=\"text/html;charset=KSC5601\" %>
<%
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(\"jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:o
racle\",\"scott\",\"tiger\");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(\"select * from BONUS\");
if (rs==null)
{
out.println(\"¾Ï°Íµµ ¾ø´Ù\");
}
else
{
out.println(\"¹º°¡ ÀÖ´Ù\");
}
stmt.close();
conn.close();
%>
¿©±â¿¡¼ DriverManager.getConnection(\"jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:o
racle\",\"scott\",\"tiger\")´Â ¾Æ·¡¿Í °°´Ù.
DriverManager.getConnection(\"jdbc:µå¶óÀ̹ö:thin:@¿À¶óŬ ¼¹ö IP:1521:DB ¸í\",\"DB User\",\"DB Pass\");
À¥¿¡¼ È®ÀÎÀ» ÇÑ´Ù.
http://domain:8080/oracle.jsp
¿©±â¼ ÇÊÀÚÀÇ °æ¿ì \"¹º°¡ ÀÖ´Ù\"°¡ Ãâ·ÂµË´Ï´Ù. \"¹º°¡ ÀÖ´Ù\" ¶óµç°¡ \"¾Ï°Íµµ ¾ø´Ù\"°¡ Ãâ·ÂµÇ¸é ¼º°ø.. ÃßÄ«ÃßÄ«
%%%%%%%%%%%%%%%%%%%%%%%%%
** tomcat/common/lib/tools.jar¸¦ /usr/java/lib/tools.jar¿¡ copyÇØ¾ß ÇÑ´Ù... (¸¸¾à Ŭ·¡½ºÆнº°¡ /usr/java/lib/tools.jar·Î µÇ¾îÀÖ´Ù¸é..)
|