当前位置: 代码迷 >> Java Web开发 >> jsp的数据库连接有关问题,求教,
  详细解决方案

jsp的数据库连接有关问题,求教,

热度:11   发布时间:2016-04-17 15:23:37.0
jsp的数据库连接问题,求教,急!!!!!!!!!!!!!!!!!!!!!

<%@   page   language= "java "   import= "java.util.* "   pageEncoding= "UTF-8 "%>
<%@   page   import= "java.sql.* "%>
<%
String   path   =   request.getContextPath();
String   basePath   =   request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">
<html>
    <head>
        <base   href= " <%=basePath%> ">
       
        <title> My   JSP   'sqlconn.jsp '   starting   page </title>
       
        <meta   http-equiv= "pragma "   content= "no-cache ">
        <meta   http-equiv= "cache-control "   content= "no-cache ">
        <meta   http-equiv= "expires "   content= "0 ">
        <meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
        <meta   http-equiv= "description "   content= "This   is   my   page ">
       
        <!--
        <link   rel= "stylesheet "   type= "text/css "   href= "styles.css ">
        -->
    </head>
   
    <body>
    <%
          Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();  
           
  String   url= "jdbc:microsoft:sqlserver://172.19.140.222:1433;DatabaseName=pubs ";  

  //pubs为你的数据库的  

  String   user= "sa ";  

  String   password= "123 ";  
 
  //Connection   conn=   DriverManager.getConnection(url,user,password);  
 
  //Statement   stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
    %>
   
        This   is   my   JSP   page.   <BR> <%=url%> <br>
    </body>
</html>

报错:
type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

javax.servlet.ServletException:   No   suitable   driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.sqlconn_jsp._jspService(org.apache.jsp.sqlconn_jsp:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
  相关解决方案