当前位置: 代码迷 >> Java Web开发 >> JSP连接MySQL有关问题
  详细解决方案

JSP连接MySQL有关问题

热度:15   发布时间:2016-04-17 12:55:26.0
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.daimami.com/search?q=2308
  相关解决方案