求大神:我在myeclipse 连接 sql server 2005 时,老是出现连接问题,提示找不到:jdbc 中的类,帮忙解决
为题代码:org.apache.jasper.JasperException:AnexceptionoccurredprocessingJSPpage/testMssql...
为题代码:org.apache.jasper.JasperException: An exception occurred processing JSP page /testMssql.jsp at line 25
22: %>
23: <%
24:
25: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
26: Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev","bn","bn");
27: Statement stmt=con.createStatement();
28: ResultSet rst=stmt.executeQuery("select * from book;");
root cause
出错的解释:
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
经过努力:现在出现新的问题了。
javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'book' 无效。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
程序代码:
Class.forName(driverName);System.out.println("Connection Successful!"); Connection con = DriverManager.getConnection(dbURL, userName, userPwd);
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery("select * from user_info;"); 展开
22: %>
23: <%
24:
25: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
26: Connection con=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jspdev","bn","bn");
27: Statement stmt=con.createStatement();
28: ResultSet rst=stmt.executeQuery("select * from book;");
root cause
出错的解释:
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:110)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
经过努力:现在出现新的问题了。
javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 'book' 无效。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.testMssql_jsp._jspService(testMssql_jsp.java:123)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
程序代码:
Class.forName(driverName);System.out.println("Connection Successful!"); Connection con = DriverManager.getConnection(dbURL, userName, userPwd);
Statement stmt = con.createStatement();
ResultSet rst = stmt.executeQuery("select * from user_info;"); 展开
6个回答
展开全部
com.microsoft.jdbc.sqlserver.SQLServerDriver确认一下是否完整类名敲对
更多追问追答
追问
我好像没有错的,Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection con=java.sql.DriverManager.getConnection("jdbc:sqlserver://127.0.0.1:1433;DatabaseName=jspdev","test","test");
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select * from book;");
追答
com.microsoft.sqlserver.jdbc.SQLServerDriver你和我的对照仔细看看?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你的jar包是复制到WEB-INF目录下的jar里面吗?
追问
我是直接导入外部JAR 的,但是你说的方法我也试过了。
我在想是不是我的版本为题:MyEclipse 9.0 ; jdk 1.6以上的 ; jdbc 官方4.0 的
我的这些可以用的吗?是不是就是他们出的问题。
追答
怎么没写try catch 语句呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sql Server的驱动包没拷进去
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
是不是没到入驱动包啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没看明白
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询