易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP连接ACCESS数据库的简单代码

连接ACCESS数据库的简单JSP代码:
  <%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ page import="java.sql.*" %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=" + application.getRealPath("jsp.mdb"); //与JSP文件同一目录下的ACCESS数据库文件名:jsp.mdb
Connection conn = DriverManager.getConnection(url,"",""); //连接ACCESS数据库(url,"用户名","密码"),为空即没有设置数据的登录密码。
Statement stmt=conn.createStatement();

String sql="select * from login"; //构造SQL语句

ResultSet rs=stmt.executeQuery(sql);

while(rs.next()){
int id=rs.getInt("id"); //得到数据库里面的字段id的值。
String username=rs.getString("username"); //得到数据库里面的字段username的值。
String password=rs.getString("password");
}

//关闭与数据库的连接
rs.close();
stmt.close();
conn.close();

}
catch(Exception e)
{
e.printStackTrace();
}
%>

</table>
</center>
<html>
<head>
<title>连接数据库</title>
</head>
<body>
</body>
</html>


相关文档:

jsp运行时经常遇到的几个问题

1、如何显示目录列表:
我们在本机测试程序时,一般都习惯在浏览器中就能遍历到某个目录下都有哪些文件,这就需要web服务器支持目录列表:
打开文件conf/web.xml,找到以下代码:
<param-name>listings</param-name>
<param-value>false</param-value>
将其中的false改成true
2、配置error-p ......

checkbox 在jsp中的使用

 本文作者:佚名
所属分类:网络编程
加入时间:2006-1-19
点击次数:396
<%@ page language="java" contentType="text/html" %>
<%@ page import="com.ora.jsp.util.*" %>
<html>
<body bgcolor="white">
<form action="checkbox.jsp">
<input type="checkbox" name="fr ......

Access Code + Fingerprint Door Lock

Double action
fingerprint
and access code security door lock for your home,
office or small business. Get modern biometric security at your entry point with
this standard door handle style double action doorlock.
This is the most secure and convenient method in assuring only authorized peo ......

struts2中action获取jsp页面参数

转自:http://hi.baidu.com/346667002/blog/item/e58edef0d599fcc97831aa18.html
1. ActionContext
在Struts2开发中,除了将请求参数自动设置到Action的字段中,我们往往也需要在Action里直接获取请求(Request)或会话
(Session)的一些信息,甚至需要直接对JavaServlet
Http的请求(HttpServletRequest),响应(HttpServletRes ......

JSP分页技术

在使用数据库的过程中,不可避免的需要使用到分页的功能,可是JDBC的规范对此却没有很好的解决。对于这个需求很多朋友都有自己的解决方案,比如使用Vector等集合类先保存取出的数据再分页。但这种方法的可用性很差,与JDBC本身的接口完全不同,对不同类型的字段的支持也不好。这里提供了一种与JDBC兼容性非常好的方案。
JD ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号