求解!!MyEclipse抛出的异常!!

sunshineboyy 2011-04-22 06:51:28
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /denglu.jsp at line 25

22: username=request.getParameter("username");
23: pwd=request.getParameter("pwd");
24: Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
25: Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");
26: Statement stmt=conn.createStatement();
27:
28: ResultSet rs=stmt.executeQuery("select * from zhucebiao where username=\'"+username+"\' and password=\'"+pwd+"\'");


求解这些异常!!!多谢
...全文
246 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
WADS913 2011-04-26
  • 打赏
  • 举报
回复
你用的sql版本是多少的?
然后看你导入包对不对。你现在的Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");是sql2000的。
如果是2005的话应该是
conn=DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DataBaseName=company","sa","sa");
没有那个:microsoft:
24K純帥 2011-04-25
  • 打赏
  • 举报
回复
数据库木有连上啊,具体点是有什么错呢
sunshineboyy 2011-04-25
  • 打赏
  • 举报
回复
项目里没源代码,是重新做一个项目还是?????O(∩_∩)O谢谢
taojay315 2011-04-23
  • 打赏
  • 举报
回复
建议写进DAO里吧 写进jsp里有错误实在不好弄
taojay315 2011-04-23
  • 打赏
  • 举报
回复
你不是25行出错么?
你看一下conn的值啊 是否建立成功
sunshineboyy 2011-04-23
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 taojay315 的回复:]
唉 现在怎么都不用debug了呢。。
即使不用debug 你用个最简单的方法 System.out.println一下啊。。。
[/Quote]
这就是数据库驱动Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
taojay315 2011-04-23
  • 打赏
  • 举报
回复
唉 现在怎么都不用debug了呢。。
即使不用debug 你用个最简单的方法 System.out.println一下啊。。。
xdrs1314 2011-04-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ylz2007 的回复:]

第25行,try catch一下就知道什么问题了。
[/Quote]+1 错误信息看下,我想应该是你没有导入sqlserver驱动jar.
yangkun880615 2011-04-23
  • 打赏
  • 举报
回复
凡是连接数据库 都要抛出个异常,你try{

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=liuyanban","sa","123qwe");
Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery("select * from zhucebiao where username=\'"+username+"\' and password=\'"+pwd+"\'");




}catch(Exception e){e.printStackTrace();}
hepeng_8 2011-04-22
  • 打赏
  • 举报
回复
try catch 25行 试试
sunshineboyy 2011-04-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dgcxyc 的回复:]
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
这里应该是com.microsoft.jdbc.sqlserver.SQLServerDriver吧、
[/Quote]
我是照着书上写的,没弄错啊
dgcxyc 2011-04-22
  • 打赏
  • 举报
回复
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
这里应该是com.microsoft.jdbc.sqlserver.SQLServerDriver吧、
daishunchaoaiqiu 2011-04-22
  • 打赏
  • 举报
回复
没有抛出异常
<%
try
{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("....");
}catch(Exception e){out.println("shibai");}
%>
PS:把数据库的东西写到一个类中,然后调用比较好。。。
PreparedStatement可以代替Statement了。。。
  • 打赏
  • 举报
回复
第25行,try catch一下就知道什么问题了。

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧