IT猫扑网:您身边最放心的安全下载站! 最新更新|软件分类|软件专题|手机版|论坛转贴|软件发布

您当前所在位置:首页操作系统LINUX → RedHatLinux网络服务器构架实务(八)

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

时间:2015/6/28来源:IT猫扑网作者:网管联盟我要评论(0)

//获取字段值,参数为字符串--字段名
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两部分

关键词标签:实务,构架,网络服务,#

相关阅读

文章评论
发表评论

热门文章 安装红帽子RedHat Linux9.0操作系统教程安装红帽子RedHat Linux9.0操作系统教程使用screen管理你的远程会话使用screen管理你的远程会话GNU/Linux安装vmwareGNU/Linux安装vmware如何登录linux vps图形界面 Linux远程桌面连如何登录linux vps图形界面 Linux远程桌面连

相关下载

人气排行 Linux下获取CPUID、硬盘序列号与MAC地址linux tc实现ip流量限制dmidecode命令查看内存型号安装红帽子RedHat Linux9.0操作系统教程linux下解压rar文件lcx.exe、nc.exe、sc.exe入侵中的使用方法Ubuntu linux 关机、重启、注销 命令查看linux服务器硬盘IO读写负载