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

非高手不可!jsp连接sqlserver2000出现No suitable driver?
我把驱动包(4个,包括jtds包)已经放到lib目录下了,我用jtds就可以连上

<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.*,java.io.* "   errorPage= " "%>
<%
Class.forName( "net.sourceforge.jtds.jdbc.Driver ");  
//String   url   =   "jdbc:jtds:sqlserver://localhost:1433/mydb ";
String   url=  
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb ";
Connection   con   =   java.sql.DriverManager.getConnection(url, "sa ", " ");
PreparedStatement   pstmt   =   con.prepareStatement( "select   *   from   course ");
ResultSet   rs   =   pstmt.executeQuery();
out.println( " <table> ");
while(rs.next())
{
out.println( " <tr> ");
out.println( " <td> "+rs.getString(1)+ " </td> ");
out.println( " <td> "+rs.getString(2)+ " </td> ");
out.println( " <td> "+rs.getString(3)+ " </td> ");
out.println( " <td> "+rs.getString(4)+ " </td> ");
out.println( " <td> "+rs.getString(5)+ " </td> ");
out.println( " </tr> ");
}
out.println( " </table> ");
%>
网上找了好久都没找到解决方法?请指点下

------解决方案--------------------
Class.forName( "com.micrsosoft.jdbc.Driver ")
试试