| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:求助 谢谢!!!!!!!!!
只看楼主 加入收藏
xf123
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-12-28
收藏
 问题点数:0 回复次数:1 
求助 谢谢!!!!!!!!!

编译下列程序连接数据库出现错误,帮忙看一下,请各位高手帮忙!!!具体如何解决!!
buybook.java

//订购页面使用的bean
package ToLineBook;
import java.sql.*;
public class BuyBook{
long id=0;
String order_number,book_name;
String serverName = "localhost";
String sConnStr = "jdbc:microsoft:sqlserver://locahost:1433;DatabaseName=xf";
Connection con;
Statement sql;
ResultSet rs;
public BuyBook()
{
//加载驱动器
try{Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");}
catch(ClassNotFoundException e){}
}
//设置属性值,获取属性值的方的方法.
public void setId(long n)
{
id=n;
}
public long getId()
{
return id;
}
public void setOrder_number(String number)
{
order_number=number;
}
public String getOrder_number()
{
return order_number;
}
public void setBook_name(String name)
{
book_name=name;
}
public String getBook_name()
{
return book_name;
}
//通过id查询图书列表
public StringBuffer getMessageBuybook_id()
{
StringBuffer buffer=new StringBuffer();
try{
con=DriverManager.getConnection(sConnStr,"sa","xf");
sql=con.createStatement();
String condition="SELECT*FROM bookWHERE id="+id;
rs=sql.executeQuery(condition);
buffer.append("<Table Border><font size=1>");
buffer.append("<TR>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"id"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"订购号"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"书名"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"作者"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"出版社"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"出版时间"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"单价"+"</font>");
buffer.append("<TH wodth=50>"+"<font size=1>"+"类别"+"</font>");
buffer.append("</TR>");
while(rs.next())
{
order_number=rs.getString(2);
book_name=rs.getString(3);
String 作者=rs.getString(4);
String 出版社=rs.getString(5);
Date 出版时间=rs.getDate(6);
String 单价=rs.getString("price");
String 类别=rs.getString("category");
buffer.append("<TR>");
buffer.append("<TD>"+"<font size=1>"+rs.getLong(1)+"</font>");
buffer.append("<TD>"+"<font size=1>"+order_number+"</font>");
buffer.append("<TD>"+"<font size=1>"+book_name+"</font>");
buffer.append("<TD>"+"<font size=1>"+作者+"</font>");
buffer.append("<TD>"+"<font size=1>"+出版社+"</font>");
buffer.append("<TD>"+"<font size=1>"+出版时间+"</font>");
buffer.append("<TD>"+"<font size=1>"+单价+"</font>");
buffer.append("<TD>"+"<font size=1>"+类别+"</font>");
buffer.append("</TR>");
}
buffer.append("</Table>");
buffer.append("</font>");
con.close();
return buffer;
}
catch(SQLException e)
{
return buffer;
}

}
}
出现以下异常情况!!!!!!!!!!!!!!!!!!
exception

javax.servlet.ServletException: com/microsoft/jdbc/base/BaseDriver
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.buybook$jsp._jspService(buybook$jsp.java:355)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
root cause

java.lang.NoClassDefFoundError: com/microsoft/jdbc/base/BaseDriver
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at org.apache.catalina.loader.StandardClassLoader.findClass(StandardClassLoader.java:674)
at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:1093)
at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClassLoader.java:992)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1392)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1254)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at ToLineBook.Login.(Login.java:20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at java.beans.Beans.instantiate(Beans.java:204)
at java.beans.Beans.instantiate(Beans.java:48)
at org.apache.jsp.buybook$jsp._jspService(buybook$jsp.java:101)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter

2005-12-28 18:13
rngguliu
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-12-30
收藏
得分:0 

可能是没有加载jdbc驱动吧

2005-12-31 08:06
快速回复:求助 谢谢!!!!!!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029823 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved