数据库连接问题,请大家务必帮忙!多谢多谢

dzeng81 2006-04-16 10:50:53
错误提示如下:
严重: Servlet.service() for servlet jsp threw exception
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:127)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at org.apache.jsp.login_jsp._jspService(org.apache.jsp.login_jsp:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1203)
at java.lang.Thread.run(Thread.java:595)
...全文
125 6 点赞 打赏 收藏 举报
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
yown 2006-04-18
确定安装好jdbc
  • 打赏
  • 举报
回复
dzeng81 2006-04-17
对了,忘了说我的操作系统是windows2003 Server+sp1
数据库SQL Server2000没有打补丁包
请大家再帮我分析下原因,我真的很急,白天上班,晚上才有时间搞毕业设计
郁闷啊,请各位大哥大姐帮帮忙
时间有点紧,多谢多谢
  • 打赏
  • 举报
回复
wsk_228 2006-04-17
去掉这行试试 <%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
  • 打赏
  • 举报
回复
spliky 2006-04-17
分别Jdbc安装针对windows和SqlServer的补丁,google下就知道了
  • 打赏
  • 举报
回复
dzeng81 2006-04-16
请大家一定要帮忙,看看我是哪里出错了,我的JDBC文件不管是放在工程目录的中的web-inf/lib下还是放在/Tomcat5.5/common/lib下都存在上面这个问题。
在此多谢大家了,谢谢
  • 打赏
  • 举报
回复
dzeng81 2006-04-16
请问大家这是什么问题
我的代码是这样的
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<%@ page import="java.lang.*"%>

<%
request.setCharacterEncoding("UTF-8");
String CLASSFORNAME="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String SERVANDDB="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=netstore";
String USER="javadb";
String PWD="javadb";
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆页面</title>
</head>
<body>
<%//获取请求参数
String id = request.getParameter( "userId" );
String psw = request.getParameter( "password" );

//连接数据库

Class.forName(CLASSFORNAME);
DriverManager.setLogStream( System.out );
Connection con = DriverManager.getConnection( SERVANDDB, USER, PWD );
Statement statement = con.createStatement();
String isCorrect = "select * from user_info where userId='" + id
+ "' and password='" + psw + "'";
ResultSet result = statement.executeQuery( isCorrect );
session.setAttribute( "isLog", new String( "0" ) );

if ( !result.next() )
{
response.sendRedirect( "index.jsp" ); //用户名和密码错误,转入登陆界面从新登陆;
result.close();
statement.close();
con.close();

}
//如果查询后有记录,说明登陆成功;

else
{
session.setAttribute( "name", result.getString( "name" ) );
session.setAttribute( "id", result.getString( "userid" ) );
session.setAttribute( "email", result.getString( "email" ) );
session.setAttribute( "isLog", result.getString( "1" ) );
int count = result.getInt( "userLogCount" );
session.setAttribute( "userLogCount", new Integer( count ) );
count++;
session.setAttribute( "userLastLogTime", result
.getString( "userLastLogTime" ) );
java.util.Date time1 = new java.util.Date();
String sqltime = new Timestamp( time1.getTime() ).toString();

//将当前时间转换成sql server可以识别的对象;
//更新登陆信息;
statement.execute( "update user_info set userLogCount=" + count
+ ",userLastLogTime='" + sqltime + "'where userId='"
+ id + "'" );

statement.close();
result.close();
con.close();
response.sendRedirect( "index.jsp" );
}
%>
</body>

</html>
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
加入

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-04-16 10:50
社区公告
暂无公告