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

忙活两天了一点头绪也没有```高手进来帮帮忙``
为什么这个程序会报这样的错语

cannot   is   issue   data   manipulation   statements   with   executeQuery();请问什么原因哦``

package   beans;
import   java.sql.*;
public   class   connDB   {
Connection   conn=null;
Statement   stmt   =null;
ResultSet   rs=null;
public   connDB()
{
try   {
Class.forName( "com.mysql.jdbc.Driver ");
}   catch   (Exception   e)   {
//   TODO:   handle   exception
System.err.println(e.getMessage());
}
}
public   ResultSet   executeQuery(String   sql)
{
try   {
conn   =   DriverManager.getConnection(
"jdbc:mysql://localhost:3306/luntan ",   "root ",
"12345678 ");
stmt   =   conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs   =   stmt.executeQuery(sql);
}   catch   (Exception   ex)   {
//   TODO:   handle   exception
System.err.println(ex.getMessage());
}    
return   rs;
}
public   int   executeUpdate(String   sql)
{
int   result=0;
try   {
conn   =   DriverManager.getConnection(
"jdbc:mysql://localhost:3306/luntan ",   "root ",
"12345678 ");
stmt   =   conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs   =   stmt.executeQuery(sql);
}   catch   (Exception   ex)   {
//   TODO:   handle   exception
System.err.println(ex.getMessage());
        result=0;
}    
return   result;
}

}


<%@   page   language= "java "   contentType= "text/html;charset=gb2312 "%>
<%@   page   import= "java.sql.* "   %>
<jsp:useBean   id= "connBean "   scope= "page "   class= "beans.connDB "/>
<html>
    <head>      
        <title> My   JSP   'reg_ok.jsp '   starting   page </title>    
    </head>
    <body>
      <%
             
              String   id=request.getParameter( "id ");
              String   name=request.getParameter( "name ");
              String   password=request.getParameter( "password ");
              String   sex=request.getParameter( "sex ");
              ResultSet   rs=connBean.executeQuery( "select   *   from   register   where   username= ' "+name+ " ' ");
              System.out.println(name);System.out.println(password);
        &nbs