数据库是access文件,建立了ODBC,程序如下:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="conn" scope="page" class="conn.openDB"/>
<%@ include file="System/SysFunction.jsp" %>
<%@ include file="System/FkFunction.jsp" %>
<META http-equiv="Content-Type" content="text/html; charset=GB2312">
<META HTTP-EQUIV="Pragma" CONTENT="No-Cache">
<SCRIPT LANGUAGE="JavaScript" SRC="System/Query.js"></SCRIPT>
<TITLE></TITLE>
<LINK Rel="Stylesheet" Type="text/css" Href="../System/Query.css">
</HEAD>
<style type="text/css">
<!--
.style1 {
font-size: 20px;
font-weight: bold;
}
-->
</style><body>
<div align="center" class="style1">JSP连接Access数据库</div>
<br>
<hr>
<p>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
Connection con = DriverManager.getConnection("jdbc:odbc:db"); //建立数据库链接,jspdata为ODBC数据源名称
//建立Statement对象
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
int cc=0;
ResultSet rs = stmt.executeQuery("select * from tb1"); //建立ResultSet(结果集)对象,并执行SQL语句
//存储数据%>
</p>
<p align="center">NUMB1数据表中记录如下</p>
<table width="640" border="1" align="center" bordercolor="#7188e0">
<tr bgcolor="d1d1ff">
<th>NBH</th>
<th>XM</th>
<th>DZ</th></tr>
<%
String sql="";
int tt=0;
while(rs.next())
{   out.println("<tr>");
out.println("<td>"+rs.getString("id")+"&nbsp;</td>");
out.println("<td>"+rs.getString("zd1")+"&nbsp;</td>");
out.println("<td>"+rs.getString("zd2")+"&nbsp;</td>");
out.println("</tr>");
tt++;}
rs.close();
stmt.close(); 
con.close(); 
%>
</table>
<p align="center"><br>
如果您能看到表格中的数据,说明连接数据库成功!</p>
</body>
</html>发布环境是websphere,这个程序在我机器上是好的,我的机器是xp系统,但是放到另外一台机器上就报JDBC—ODBC错误了,错误如下:[07-5-9 14:10:30:219 CST] 7760993f WebGroup      I SRVE0180I: [web] [/] [Servlet.LOG]: /new.jsp: init
[07-5-9 14:10:30:312 CST] 7760993f WebGroup      E SRVE0026E: [Servlet 错误]-[sun.jdbc.odbc.JdbcOdbcDriver]:java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java(Compiled Code))
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java(Compiled Code))
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.servlet.JasperLoader.loadClass(JasperLoader.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.servlet.JasperLoader.loadClass(JasperLoader.java(Compiled Code))
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at org.apache.jsp._new._jspService(_new.java:2938)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java(Compiled Code))
at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java(Compiled Code))
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java(Inlined Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java(Compiled Code))
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java(Compiled Code))
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java(Compiled Code))
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java(Compiled Code))
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java(Compiled Code))
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))麻烦大虾们帮我看看是怎么回事