当前位置: 首页 > 图文教程 > 服务器 > Linux服务器 > RedHatLinux网络服务器构架实务(八)

Linux服务器
搭建安全的LinuxSquid代理服务器
linux下apache+php+mysql升级安装过程
Linux服务器中OpenSSH的源码编译与升级
Linux系统下SambaServer的配置文件解析
Linux下如何同时启动多个Tomcat服务器
LinuxIPv6环境下DNS服务器配置攻略
Linux系统下SoftEther服务器的使用方法
实现Linux与宿主机之间的通信
在UbuntuLinux下配置静态DNS
服务器维护:RHEL5系统下故障处理方法
FedoraLinux系统Samba服务器架设
RHEL5Squid透明代理服务器配置过程解析
SlackwareEyooLinux服务器配置相关指令
DebianLinux系统Socks5服务器安装方法
RedHatAS5整合Apache和Tomcat服务器应用
巧用cfengine管理linux服务器
Linux服务器装机安全快速进阶指南
新手学堂:Linux操作系统配置Vsftp方法
利用UNIX系统的TFTP和RCP配置路由器
解决Linux服务器下误删除文件的问题

Linux服务器 中的 RedHatLinux网络服务器构架实务(八)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-18   浏览: 69 ::
收藏到网摘: n/a


//获取字段值,参数为字符串--字段名
publicStringgetString(StringfieldName)
throwsSQLException{
 returnrs.getString(fieldName);
}

//上移指针
publicbooleanprevious()
throwsSQLException{
 if(rs==null)
thrownewSQLException("ResultSetisnull.");
 returnrs.previous();
}

//下移指针
publicbooleannext()
throwsSQLException{
 if(rs==null)
thrownewSQLException("ResultSetisnull.");
 returnrs.next();
}

//指针最上
publicbooleanfirst()
throwsSQLException{
 if(rs==null)
thrownewSQLException("ResultSetisnull.");
 returnrs.first();
}

//指针最下
publicbooleanlast()
throwsSQLException{
 if(rs==null)
thrownewSQLException("ResultSetisnull.");
 returnrs.last();
}

//清除变量,当你仅需要清除变量而不关库时可调用此方法
privatevoidclear()throwsSQLException{
if(rs!=null)rs.close();
 rs=null;
 if(stmt!=null)stmt.close();
 stmt=null;
}

//清除变量并关库
publicvoidclose()throwsSQLException{
 clear();
if(conn==null)
 thrownewSQLException("Thisconnectionhasbeenclosedalready.");
 if(conn.isClosed())
thrownewSQLException("Thisconnectionhasbeenclosed.");
 conn.close();
 conn=null;
}

 }

2编写逻辑层代码
##在客户端创建dbbridge.jsp,然后上传到服务器端即可:

##上级要来视察某官僚的工作,只见该官僚指挥若定:
##逻辑层对处理层说:小子,去跟我的后台联络一下。//连库并初始化
<jsp:useBeanid="bridge"class="com.gledecity.yesgo.sql.DBBridge"/>
##逻辑层对处理层说:把我们今年的工作成果准备一下。//执行SQL语句
<%bridge.execSQL("select*fromprov");
##逻辑层对处理层说:材料准备好了?干得好!上级一来看到一片数据。//循环显示
while(bridge.next())
{out.print(bridge.getString("prov_id")+bridge.getString("prov_name")+"<br>");}
##逻辑层对处理层说:好了好了,政绩显示完毕,你们通通滚蛋吧。//关闭所有变量
bridge.close();%>
##上级看后非常满意,拍拍官僚的肩膀:"干得不错!"官僚一高兴,说:"哪里哪里,都是下属办事得力!"

3测试该程序
lynxhttp://www.yesgo.loc/dbbridge.jsp
##当然你也可以在客户端浏览器测试,只是你需要将你服务器的IP添加到你网络设置中的DNS列表中。

##处理的结果是数据库中所有的数据:

1安徽
2北京
3重庆
4福建
5甘肃
6广东
7广西
8贵州
9海南
10河北
11黑龙江
12河南
13湖北
14湖南
15内蒙古
16江苏
17江西
18吉林
19辽宁
20宁夏
21青海
22山西
23陕西
24山东
25上海
26四川
27天津
28西藏
29新疆
30云南
31浙江
32香港
33澳门
34台湾

例四:测试PHP
1创建源文件
touch/home/www/test.php
chmod701/home/www/test.php

2编辑源文件
vitest.php
##源代码如下:
<?
phpinfo();
?>

3测试该程序
lynxhttp://www.yesgo.loc/test.php
//结果是大家熟知的服务器端变量列表。

Step17Configurationdebug

##调试过程可能的错误如下:

常见错误一:Youdon'thavepermission

Forbidden
Youdon'thavepermissiontoaccess/onthisserver.

Apache/1.3.22Serveratwww.yesgo.locPort80

原因可能是:

1、你没有为该目录或者该文件设置guest组权限;
2、你没有将该文件名设置为默认页面,尤其是在仅用域名访问的情况下。
解决办法:
chmod701/home/www
chmod701/home/www/*

vi/usr/local/apache/conf/httpd.conf
DirectoryIndexindex.htmlindex.jspindex.xtpindex.phpindex.php3

常见错误二:404NotFound

404NotFound
/index.jspwasnotfoundonthisserver.

Resin2.0.5(builtThuNov1517:56:24PST2001)

原因可能是:
1、你请求的文件名输入错误;
2、你没有在resin.conf和httpd.conf中都建立相应的主机。

解决办法:
1、检查文件名,尤其注意大小写问题;
2、参照Resininstall步骤中的配置支持JSP的虚拟主机部分。

常见错误三:java.lang.ClassNotFoundException

500ServletException
java.lang.ClassNotFoundException:org.gjt.mm.mysql.Driver
atcom.caucho.util.DynamicClassLoader.loadClass(DynamicClassLoader.java:479)
atjava.lang.ClassLoader.loadClass(ClassLoader.java:253)
atjava.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
atjava.lang.Class.forName0(NativeMethod)
atjava.lang.Class.forName(Class.java:120)
at_cnmysql__jsp._jspService(/cnmysql.jsp:4)
atcom.caucho.jsp.JavaPage.service(JavaPage.java:74)
atcom.caucho.jsp.Page.subservice(Page.java:485)
atcom.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:176)
atcom.caucho.server.http.Invocation.service(Invocation.java:278)
atcom.caucho.server.http.CacheInvocation.service(CacheInvocation.java:129)
atcom.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:338)
atcom.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:270)
atcom.caucho.server.TcpConnection.run(TcpConnection.java:140)
atjava.lang.Thread.run(Thread.java:484)

Resin2.0.5(builtThuNov1517:56:24PST2001)

原因可能是:
1、你没有安装驱动程序;
2、驱动程序没有设置到系统CLASSPATH中。

解决办法:
参见ClassesInstall和edit/etc/profile两部分