急!!!在线等!谢谢
连接sqlserver:
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mybase";
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from haha";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){%>
您的第一个字段内容为:<%=rs.getString(1)%>
您的第二个字段内容为:<%=rs.getString(2)%>
<%}%>
<%out.print("数据库操作成功,恭喜你");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
出现以下界面:
javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SQLServerDriver at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471) at org.apache.jsp.test$jsp._jspService(test$jsp.java:118) 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) 。。。。。。。。root cause
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1406) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1254) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:198) at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315) 。。。。。。。。大侠们指导指导,十分感谢!!!
搜索更多相关主题的帖子:
在线
----------------解决方案--------------------------------------------------------
实在是搞晕了。
麻烦大虾们给讲讲
谢谢了
----------------解决方案--------------------------------------------------------
看起来是你的数据库没连上,你的数据库驱动没安装好!
----------------解决方案--------------------------------------------------------