上一篇:使用JavaBean,一句代码完成对文本文件读取和写… >>
jsp与javaBeans的结合使用
*********operateDB.jsp************
<html>
<head><title></title></head>
<body>
<jsp:userBean id="selectDB" class="javaBean生成的class文件的路径" scope="page">
////数据查询方面
<%
selectDB.setcon("jdbc:odbc:数据源名称","sql查询语句");
selectDB.getcon();
while(selectDB.rs.next())
{
out.println(selectDB.rs.getString("相应字段"));
}
%>
////数据更新方面
<%
selectDB.setcon("jdbc:odbc:数据源名称","sql更新\删除\插入语句");
selectDB.getcon();
%>
</jsp:userBean>
</body>
</html>
********javaBean文件********
package count;
import java.sql.*;
public class odbcconnection
{
public ResultSet rs;
String strsql,odbcpath;
public void setcon(String path,String sql)
{
odbcpath=path;
strsql=sql;
}
public void getcon()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(odbcpath);
Statement stmt=con.createStatement();
if(strsql.substring(0,6).equals("select"))
{rs=stmt.executeQuery(strsql);}
else
{stmt.execute(strsql);}
}catch(Exception s){}
}
}
下一篇:关于seeion的文章 >>
相关文章:
- · 关于pasv模式中,数据端口由谁指定?
- · Vsftpd1.2.0的高级配置篇
- · Vsftpd1.2.0的基础配置篇
- · SERV-U 6002版安全设置全攻略(3)
- · SERV-U 6002版安全设置全攻略(2)
- · SERV-U 6002版安全设置全攻略(1)
- · SERV-U 6002版安全设置全攻略(4)
- · FTP的建立与维护
- · 用SSL加密增强FTP服务器安全性
- · 教你如何巧妙设定匿名FTP的安全
- · 创建IIS6.0下用户隔离模式FTP站点
- · Secure FTP:安全的企业级FTP服务器
- · BulletProof FTP Server:物美价廉
- · ArGoSoft FTP服务器:架设只要一分钟
- · FTP服务器架设--管理篇
- · FTP服务器架设--架设篇
- · FTP服务器架设--安全篇
- · serv-U FTP软件的攻击防守
- · FTP服务器快速架设全功略
- · IIS建立FTP就真的那么弱吗
- · 关于ftp服务程序中不安全因素研究
- · FTP服务器安全
- · FTP服务器端软件Serv-U教程(6)
- · FTP服务器端软件Serv-U教程(2)
- · FTP服务器端软件Serv-U教程(5)
- · FTP服务器端软件Serv-U教程(3)
- · FTP服务器端软件Serv-U教程(1)
- · FTP服务中允许上传权限存在的问题
- · 内网FTP服务器架设不完全解析
- · Linux下FTP的配置与应用
- · wingate FAQ大全
- · SyGate安装前奏
- · Leapftp的安全问题
- · FTP命令详解
- · 站点FTP参数设置
- · Linux服务器设置指南-代理接入服务器(2)4
- · Linux服务器设置指南-代理接入服务器(1)2
- · Linux下安PHP,APACHE,MYSQL,PERL方法3
