分类: LINUX
2008-04-22 13:40:05
1 下载安装文件
1) jdk-1_2_2_017-linux-i586.tar.gz
下载地址
2) jakarta-tomcat-4.1.31.tar.gz
下载地址
3) mysql-connector-java-3.1.6.tar.gz
下载地址http://dev.mysql.com/downloads/connector/j/3.1.html
2 用root身份安装jdk,tomcat,mysql驱动
1) 拷贝安装文件到/usr/local/目录
cp /root/src/jdk-1_2_2_017-linux-i586.tar.gz /usr/local/
cp /root/src/tar -zxvf ./jakarta-tomcat-
cp /root/src/tar -zxvf ./mysql-connector-java-3.1.6.tar.gz /usr/local/
2) 解包
cd /usr/local
tar -zxvf ./jdk-1_2_2_017-linux-i586.tar.gz
tar -zxvf ./jakarta-tomcat-4.1.31.tar.gz
tar -zxvf ./mysql-connector-java-3.1.6.tar.gz
3) 删除原安装文件
rm -f ./*.tar.gz
4) 拷贝mysql驱动
cp ./mysql-connector-java-3.1.6/mysql-connector-java-3.1.6-bin.jar
./jakarta-tomcat-4.1.31/webapps/ROOT/WEB-INF/lib/
3 配置JDK环境变量
修改/etc/profile,加入如下几行
JAVA_HOME=/usr/local/jdk
JRE=/usr/local/jdk1.2.2/jre
CLASSPATH=$JAVA_HOME/lib:$JRE/lib:/usr/local/jakarta-tomcat-4.1.31/webapps/ROOT/WEB-INF/lib/mysql-connector-java-3.1.6-bin.jar:.
PATH=$PATH:$JAVA_HOME/bin:$JRE/bin:.
export
JAVA_HOME JRE CLASSPATH
export PATH
4 启动TOMCAT
/usr/local/jakarta-tomcat-
5 关闭TOMCAT
/usr/local/jakarta-tomcat-
6 写mysql.jsp 测试
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/phpbb?user=phpbb&password=phpbb&useUnicode=true&characterEncoding=8859_1";
Connection conn= DriverManager.getConnection(url);
Statement
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="show tables";
ResultSet rs=stmt.executeQuery(sql);%>
<%while(rs.next()) {%>
<%=rs.getString(1)%>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>
7 外部测试地址