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

Linux服务器
在Linux下建立VPN服务器来做加密代理
有备无患Linux服务器备份和恢复技巧
如何测试和调试Apache服务器
在Linux系统下面架设Sendmail服务器
Linux操作系统下NFS服务的搭建过程
Linux操作系统下SAMBA服务的搭建过程
使用Linux应用服务器场的远程计算
高效配置Linux代理服务器Squid介绍
基于FedoraCoreNFS服务器搭建过程
sendmail+squirrelmail设置邮件服务器
用VSFTPD搭建FTP服务器
在Centos5环境下搭建安全的SSH服务器
实例解析DHCP服务器单子网配置应用
Linux系统服务器网络安全管理小技巧
Debian学习Linux系统服务器的搭建方法
NFS(网络文件系统)的建立与配置方法
Linux上的heartbeat双机热备服务架设
基于Linux系统服务器优化及安全配置
高手进阶Linux架设最简单的VPN系统
Linux系统服务器安装后的安全配置

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-18   浏览: 68 ::
收藏到网摘: 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两部分