JSP连接MySQL问题
代码是:
<%@ page contentType= "text/html;charset=GB2312 " %>
<%@ page language= "java " import= "java.sql.* "%>
<%
java.sql.Connection conn;
java.lang.String strConn;
Class.forName( "org.gjt.mm.mysql.Driver ").newInstance();
conn= java.sql.DriverManager.getConnection( "jdbc:mysql://localhost/test ", "root ", "lifewood ");
statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery( "select * from wip ");
%>
错误是:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 8 in the jsp file: /index.jsp
statement cannot be resolved to a type
5: java.lang.String strConn;
6: Class.forName( "org.gjt.mm.mysql.Driver ").newInstance();
7: conn= java.sql.DriverManager.getConnection( "jdbc:mysql://localhost/test ", "root ", "lifewood ");
8: statement stmt=conn.createStatement();
9: ResultSet rs=stmt.executeQuery( "select * from wip ");
10: %>
------解决方案--------------------statement stmt=conn.createStatement();
-->
Statement stmt=conn.createStatement();
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.aiyiweb.com/j2ee/2308.html