给你什么错误了?
见你你把第二个sql out.print()出来,然后到数据库里看看能不能select出来
你的photo_or_not是什么字段?和photo_not不一样码?

解决方案 »

  1.   

    photo_or_not 是member_base的字段我用<%=sqlphoto%>输出的SQL语句在数据库里面运行正确可以输出,但是用rs2就错误高手们怎么回事。是不是当rs没有关闭的时候不能用rs2??
      

  2.   

    关注,你的dbconn是什么东西?
    dbconn.executeQuery(sqlphoto);
    这一句我觉得有点怪!~
      

  3.   

    rs.getString("member_base.photo_or_not")能这样用吗?我不是很了解!建议你去查一下能不能这样用!
      

  4.   

    我也觉得是你的
    dbconn.executeQuery(sqlphoto);
    这句话出了问题,dbconn是不是你的数据库的连接,应该用一个Statement变量才有executeQuery这类的方法吧。
      

  5.   

    另外你这句话:
    if(rs.getString("member_base.photo_or_not").equals("yes"))
    最好用:
    if(rs.getString("member_base.photo_or_not").trim().equals("yes"))
    因为从数据库中读取数据时会把空格带进来,这样可能造成不相等。
      

  6.   

    说错了,应把上句改为:
    if(rs.getString("photo_or_not").trim().equals("yes"))
      

  7.   

    为什么要多此一举呢,一个SQL语句就可以了
    select member_photos.file from member_base,member_detail,member_photos where member_base.id>0 and gander=1 and photo_not='yes' and …… and member_photos.memberid = member_base.id order by memberid desc limit 0,1
      

  8.   

    if("yes".equals(rs.getString("member_base.photo_or_not").trim()))
      

  9.   

    同意 zwzhero(令狐冲) !
    我很不明白你为什么用rs2=dbconn.executeQuery(sqlphoto);???不都是使用statement或者preparedStatement吗?会不会你在执行rs2=dbconn.executeQuery(sqlphoto);这句话的时候,根本就是在一个已经关闭的statement上执行的?会不会又是两个执行语句都在一个statement上执行的呢?看不全你的程序,只能猜猜了,最好把你的dbconn是个什么东西也贴出来
      

  10.   

    package net.guapi;import java.io.*;
    import java.text.*;
    import java.util.*;
    import java.net.URL;
    import java.sql.*;public class dbconn 
    {
    private String connStr="jdbc:mysql://localhost:3306/love?useUnicode=true&characterEncoding=gb2312";
    private String connUser="root";
    private String connPass="";
    //static final String connDriver = "com.mysql.jdbc.Driver";
    static final String connDriver = "org.gjt.mm.mysql.Driver"; //数据驱动
            
    private Connection conn=null;
    private Statement stmt=null;
                    ResultSet rs=null;
    public String strErrorMsg = "Nothing"; public dbconn() {

    try{
    Class.forName(connDriver).newInstance();; 
    conn=DriverManager.getConnection(connStr,connUser,connPass);
    }
    catch(java.lang.ClassNotFoundException e){
    System.err.println("guest():"+e.getMessage());
    }
    catch (SQLException ex){
    System.err.println ("aq.executeQuery:"+ ex.getMessage ());
    }
    }

    public ResultSet executeQuery(String sql) {
    rs=null;
    try {
    stmt = conn.createStatement();
    rs = stmt.executeQuery(sql);
    }
    catch (SQLException ex){
    System.err.println ("aq.executeQuery:"+ ex.getMessage ());
    }
    return rs;
       } public void executeUpdate(String sql){
    stmt=null;
    try {
    stmt = conn.createStatement();
    stmt.executeUpdate(sql);
    stmt.close();

    }
    catch(SQLException ex){
    System.err.println ("aq.executeQuery:"+ ex.getMessage ());
          }
    } public String tranCode(String str){
        String tempStr = "";
        if (str!=null){
    try{
    tempStr=new String(str.getBytes(),"gb2312");
    }catch (Exception ex){

    }
        }else{
    return null;
        }
            return tempStr;
            }
            
            public void closestmt(){
    try{
    stmt.close();
    }
    catch(SQLException e){
    e.printStackTrace();
    }
    } public void  closeconn(){
    try{
    conn.close();
    }
    catch(SQLException e){
    e.printStackTrace();
    }
    }
    }
      

  11.   

    我输出sql语句是正确的。。sqlphoto
    我很菜。我是在修改别人的JSP语句出现的上面问题。我上面的想法可能是错误的。望大家看了指正一下。谢谢。