日期:2014-05-18  浏览次数:20686 次

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