I want to understand if variables declared outside /inside try block are /can be accessible to
catch block as well.
Please find a code template below:
Basically can i use Stmt like this inside catch block to capture exceptions(logging errors)
void insertException()
{
Connection conn = null;
PreparedStatement stmt = null;
try
{
}
catch(SQLException sqle)
{
String expQuery = "insert into tablename values(' ', ' ',' ');
stmt = conn.prepareStatement(expQuery); -- this should be again inside a try catch block
int catch1 = stmt.executeUpdate();
}
what can be the alternative to this.
Thanks
Ekta Garg