找不到符号-JSP [英] Cannot find symbol- JSP

查看:197
本文介绍了找不到符号-JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在编写一段JDBC连接代码.
试试{
连接con = null;
PreparedStatement pstmt = null;
----------
---------
---------
/*在此声明连接*/

}
catch(ex异常)
{
out.println(无法连接");
}
终于{
pstmt.close();
con.close();
}

在这里我收到pstmt和con的错误....找不到符号.
请帮助

Dear All,

I am writing a piece of JDBC connection code.
try{
Connection con=null;
PreparedStatement pstmt=null;
----------
---------
---------
/* Declared the connection here*/

}
catch(Exception ex)
{
out.println("Unable to connect");
}
finally{
pstmt.close();
con.close();
}

Here im getting error for pstmt and con....cannot find symbol.
Kindly help

推荐答案

由于变量pstmtcontry块内声明,因此它们超出了范围(无法访问).捕获块.
将它们的声明移到try之前.

彼得
Because your variables pstmt and con are declared inside the try block, they are out of scope (cannot be accessed) in the catch block.
Move their declarations before try.

Peter


这篇关于找不到符号-JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆