高分向高手请教JDBC连接Sybase的简单问题。

ApolloXBoy 2004-02-23 07:16:32
我刚接触WebSphere,正在开发一个WebSphere 4.0 + Sybase 11.9.2的程序。
我按照网上敲了一个例子程序,却出现如下结果:

[Jsp文件]
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>

<HTML>
<HEAD>
<TITLE> JSP测试SYBASE jconnect-5_2 JDBC数据库接口 </TITLE>
<META NAME="Generator" CONTENT="EditPlus2.11">
<META NAME="Author" CONTENT="naxin">
</HEAD>
<BODY>
<center>JSP测试SYBASE jconnect-5_2 JDBC数据库接口</center>
<BR><BR>
<table border=3 align=center >
<%
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
String url ="jdbc:sybase:Tds:localhost:2638";
Connection conn= DriverManager.getConnection(url, "dba","sql");
Statement stmt=conn.createStatement();
String sql="select emp_lname,dept_id,street,city,state from employee order by emp_lname";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {
out.print("<TR><TD>"+rs.getString("emp_lname")+"</TD>");
out.print("<TD>"+rs.getString("dept_id")+"</TD>");
out.print("<TD>"+rs.getString("street")+"</TD>");
out.print("<TD>"+rs.getString("city")+"</TD>");
out.print("<TD>"+rs.getString("state")+"</TD></TR>");
}
%>
</table>
<BR><HR>
<%out.print("数据库操作成功,恭喜你");%>
<%
rs.close();
stmt.close();
conn.close();
%>
</BODY>
</HTML>

[异常信息]
[04-2-22 19:43:29:984 CST] 4a15b8ce WebGroup X Servlet Error: JSPG0058E:无法装入类 com.sybase.jdbc2.jdbc.SybDriver: java.lang.ClassNotFoundException: JSPG0058E:无法装入类 com.sybase.jdbc2.jdbc.SybDriver
at org.apache.jasper.runtime.JspLoader.findClassInJar(JspLoader.java:168)
at org.apache.jasper.runtime.JspLoader.loadClass(JspLoader.java:152)
at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:142)
at _Sample_jsp_2._jspService(_Sample_jsp_2.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:323)
at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:503)
at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:651)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:721)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:374)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:118)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:134)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:239)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:154)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:317)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:391)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:274)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:144)

我设置了ClassPath,也在工程中导入JConn2.jar;

请各位高手给与解答,谢谢!
...全文
67 点赞 收藏 13
写回复
13 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
相关推荐
发帖
WebSphere
创建于2007-08-27

2608

社区成员

WebSphere 是 IBM 的软件平台。它包含了编写、运行和监视全天候的工业强度的随需应变 Web 应用程序和跨平台、跨产品解决方案所需要的整个中间件基础设施,如服务器、服务和工具。
申请成为版主
帖子事件
创建了帖子
2004-02-23 07:16
社区公告
暂无公告