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

小弟是初学者,有个问题请教
写的javabean程序  
package   bookshop;

import   java.sql.*;
import   bookshop.*;

public   class   DBSQLManager   {
protected   Connection   conn   =   null;   //Connection   对象
protected   Statement   stmt   =   null;     //Statement   对象
protected   ResultSet   rs   =   null;         //ResultSet   对象
protected   String   sqlStr;                     //SQL语句

public   DBSQLManager(){
try
{
sqlStr   =   " ";
DBConnectionManager   dcm   =   new   DBConnectionManager();
conn   =   dcm.getConnection();
stmt   =   conn.createStatement();
}
catch   (Exception   e){
System.out.println(e);
IsConnect   =   false;
}
    }
public   Statement   getStmt()   {
return   stmt;
}
public   Connection   getConn(){
return   conn;
}
public   ResultSet   getRs(){
return   rs;
}
public   void   setSqlStr(String   newSqlStr){
this.sqlStr   =   newSqlStr;
}
public   String   getSqlStr(){
return   sqlStr;
}
public   void   executeQuery()   throws   Exception   {
rs   =   stmt.executeQuery(sqlStr);
}
public   void   executeUpdate()   throws   SQLException{
if   (stmt   !=   null){
stmt.close();
stmt   =   null;
}
conn.close();
conn   =   null;
        }
}

错误是:isConnect   cannot   be   resolved  
这是怎么回事?



------解决方案--------------------
你都没声明,当然cannot be resolved
------解决方案--------------------
贊同!
------解决方案--------------------
在前面声明一下:
private boolean IsConnect=false;
------解决方案--------------------
声明下应该没问题;