易截截图软件、单文件、免安装、纯绿色、仅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 ......

JSP与Servlet的跳转及得到路径方法整理

  今天整理项目的流程,在JSP和Servlet之间跳来跳去,曾经一段时间,我都是把Servlet路径定义为“/SomeServlet”,也即定义为根目录,因为兼容性比较好,但是用了MyEclipse之后,新建的Servlet默认路径是“/servlet/SomeServlet”,这样写便于管理,另外就是更适合单独为Servlet设置Filter(关于Filter的设置可以参考 ......

Access Web System from external

Take Equity Collection System as an example, Some other office collegues want to access it from home without VPN, The way to check is:
1.  Check if it's limited in network, this needs to confirm with network people
2.  If the step 1 passed, get the external IP address of the system, map ......

得到access表字段名VBS脚本

 
set adoCN   =createobject("ADODB.CONNECTION")
set strCnn  =createobject("ADODB.Recordset")    
set rstSchema   =createobject("ADODB.Recordset")
  Dim   I   
dim n
        str1 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号