try{
String name= new String(request.getParameter("uid"));
String password= new String(request.getParameter("upwd"));
DataBase db= new DataBase(); //DataBase 是个数据库的类
String sql = "select * from XT_YHXX where YHMC='" + name + "' and YHMM='" + password + "' and YXBZ='Y'";
ResultSet rs=db.select(sql);
}
catch(Exception e)
{
String str = "登陆信息出错了!";
response.sendRedirect( "error.jsp?mess='" + str +"'");
}
finally
{
boolean t = db.close();
/*
if(db.close() == true)
{
if(rs!=null)
{
rs.close();
}
}
*/
} DataBase类中的 close 方法
public boolean close(){
try{
if(rs!=null){
rs.close();
}
if(stmt!=null){
stmt.close();
}
if(conn!=null){
conn.close();
}
return true;
}catch(Exception e){
System.err.println("关闭失败!");
return false;
}
}这个语句:boolean t = db.close();
放到try 最后可以执行,为什么放在finally执行不了?提示错误:
cannot resolve symbol
symbol : variable db
location: class org.apache.jsp.login_jsp
boolean t = db.close();
String name= new String(request.getParameter("uid"));
String password= new String(request.getParameter("upwd"));
DataBase db= new DataBase(); //DataBase 是个数据库的类
String sql = "select * from XT_YHXX where YHMC='" + name + "' and YHMM='" + password + "' and YXBZ='Y'";
ResultSet rs=db.select(sql);
}
catch(Exception e)
{
String str = "登陆信息出错了!";
response.sendRedirect( "error.jsp?mess='" + str +"'");
}
finally
{
boolean t = db.close();
/*
if(db.close() == true)
{
if(rs!=null)
{
rs.close();
}
}
*/
} DataBase类中的 close 方法
public boolean close(){
try{
if(rs!=null){
rs.close();
}
if(stmt!=null){
stmt.close();
}
if(conn!=null){
conn.close();
}
return true;
}catch(Exception e){
System.err.println("关闭失败!");
return false;
}
}这个语句:boolean t = db.close();
放到try 最后可以执行,为什么放在finally执行不了?提示错误:
cannot resolve symbol
symbol : variable db
location: class org.apache.jsp.login_jsp
boolean t = db.close();
解决方案 »
- 急求!!!action怎样获取FCKeditor中的值嘞!??
- 请教一个用struts1标签遍历的问题
- Thread中怎么获取到 session
- JavaWEB开发中,大家平时都用什么方式来展示前台的数据啊?
- 如何将html代码保存到数据库
- japger 和数据库相连
- jsp+tomcat,急,马上结分
- 【解惑】java nio的selector原理及非阻塞用途
- 开发web services项目的步骤。
- 急等高手指点Cookie的问题---一个用来记录用户访问次数的Cookie---在线等
- 求Mysql一个表的每个字段都可以在JSP页面点击提交后,自动删除并更新页面后不显示此字段
- poi导表问题!
放try前面我习惯,try前加一个标示变量=false,catch中=true, finally后面 if(变量){response.sendRedirect()}
String password= new String(request.getParameter("upwd"));
db= new DataBase(); //DataBase 是个数据库的类
finally
{
if(db != null) {
db.close();
}
/*