首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSP连接MySQL有关问题

2013-09-11 
JSP连接MySQL问题代码是:%@pagecontentType text/htmlcharsetGB2312 %%@pagelanguage java imp

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.myexception.cn/j2ee/2308.html

热点排行