62,629
社区成员
发帖
与我相关
我的任务
分享
public Vector select(Object pojo,String condition , String conditionValue){
Vector v = new Vector();
GetConnection getConn = null ;
SQLFactory sf = new SQLFactory(pojo);
String sql = sf.createSql(
SQLFactory.SELECT,condition,conditionValue);
try{
getConn = new GetConnection();
conn = getConn.getConnection() ;
stat = conn.createStatement();
rs = stat.executeQuery(sql);
while(rs.next()){
Vector tempV = new Vector();
tempV.add(rs.getInt(1));
tempV.add(rs.getString(2));
tempV.add(rs.getString(3));
tempV.add(rs.getString(4));
v.add(tempV);
}
}
catch(Exception err){
err.printStackTrace();
}
finally{
try {
System.out.println(rs);
if( null != rs
&& !rs.isClosed() )
rs.close();
rs = null ;
if( null != stat && !stat.isClosed())
stat.close();
stat = null ;
} catch (SQLException e) {
e.printStackTrace();
}
getConn.close();
conn = null ;
}
return v ;
}
好像不是开源的,还是找个官方文档看看吧,具体什么原因不好乱猜
有兴趣的话可以去看看源码
if( null != rs
&& !rs.isClosed() )
如果把 !rs.isCloed()去掉,程序就正常了。很纠结!
【把"&&"改成" || "是不行的】