我用的是jsp+mysql +tomcat 在连接数据库时使用如下: <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.sql.*" %> <% out.println("通讯录!");
try { Class.forName("org.gjt.mm.mysql.Driver").newInstance();
} catch (Exception E) { out.println("Unable to load driver.");
}
try { Connection C = DriverManager.getConnection("jdbc:mysql://localhost/addressbook?user=root&password=liu); Statement s=C.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY); ResultSet rs=s.executeQuery("select * from addressbook"); out.println("<table border=1>"); int i=1; for (i=10;i<20;i++) { if (rs.absolute(i)) { out.println("<tr><td>"); out.println(rs.getString(1)); out.println("</td>"); out.println("<td>"); out.print(rs.getString(2)); out.println("</td>"); out.println("<td>"); out.print(rs.getString(3)); out.println("</td></tr>"); } else { break; }
} out.println("</table>"); rs.close(); s.close(); C.close();
} catch (SQLException E) { out.println("SQLException: " + E.getMessage()); out.println("SQLState: " + E.getSQLState()); out.println("VendorError: " + E.getErrorCode()); }
%> 运行出现如下错误请 高手指教: Unable to load driver. SQLException: No suitable driver SQLState: 08001 VendorError: 0