java&SQLite ResultSet is closed 菜鸟求助 急!!
publicObjectGetObject(Stringtbl,Stringcolumn,intid)throwsSQLException{SetStrctableset...
public Object GetObject(String tbl, String column, int id) throws SQLException {
SetStrctable setStrctable = null;
int flag = 0;
if (tbl.equals("user_TBL")) {
setStrctable = new User();
flag = 1;
}
if (tbl.equals("ticket_TBL")) {
setStrctable = new Ticket();
flag = 2;
}
if (tbl.equals("hall_TBL")) {
setStrctable = new Hall();
flag = 3;
}
if (tbl.equals("cinema_TBL")) {
setStrctable = new Cinema();
flag = 4;
}
if (tbl.equals("movie_TBL")) {
setStrctable = new Movie();
System.out.println("movie");
flag = 5;
}
if (tbl.equals("issue_TBL")) {
setStrctable = new Issue();
flag = 6;
}
if (flag == 0) {
System.out.println("search by id error");
return null;
}
String sql = "select * from " + tbl + " where ? = ?";
System.out.println(sql);
Object[] objects = { column, id };
Object object = null;
try {
closeAll();
rs = query(sql, objects);
object = setStrctable.createBySet(rs);//此处rs已经是关闭的
return object;
} catch (SQLException e) {
e.printStackTrace();
return null;
} finally {
closeAll();
}
}
完整代码在这里
http://hi.baidu.com/northland89/item/656e2c294cda66d6a417b63e 展开
SetStrctable setStrctable = null;
int flag = 0;
if (tbl.equals("user_TBL")) {
setStrctable = new User();
flag = 1;
}
if (tbl.equals("ticket_TBL")) {
setStrctable = new Ticket();
flag = 2;
}
if (tbl.equals("hall_TBL")) {
setStrctable = new Hall();
flag = 3;
}
if (tbl.equals("cinema_TBL")) {
setStrctable = new Cinema();
flag = 4;
}
if (tbl.equals("movie_TBL")) {
setStrctable = new Movie();
System.out.println("movie");
flag = 5;
}
if (tbl.equals("issue_TBL")) {
setStrctable = new Issue();
flag = 6;
}
if (flag == 0) {
System.out.println("search by id error");
return null;
}
String sql = "select * from " + tbl + " where ? = ?";
System.out.println(sql);
Object[] objects = { column, id };
Object object = null;
try {
closeAll();
rs = query(sql, objects);
object = setStrctable.createBySet(rs);//此处rs已经是关闭的
return object;
} catch (SQLException e) {
e.printStackTrace();
return null;
} finally {
closeAll();
}
}
完整代码在这里
http://hi.baidu.com/northland89/item/656e2c294cda66d6a417b63e 展开
展开全部
closeAll();
数据库连接被关闭或者没打开吧
数据库连接被关闭或者没打开吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
closeAll();
rs 已经都被你关闭了,肯定要报错
rs 已经都被你关闭了,肯定要报错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把try里面的 closeAll() 方法去掉 试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询