java - Good Idea to open a connection again in Catch Block? -


i dealing jdbc connections inside try-catch block. have connection open inside try block follows:

try{  // 1 jdbc connection established here   }  catch(sqlexception ex)  {  // should open new connection here or use above one?? } 

since, want insert records once exception caught, hence wondering whether it's idea open new connection same database again connection has been established in try block ? need use different table inside catch block same database connection has been established.

please advise. thanks

the exception should create new connection closed connection. otherwise continue using same connection.

  • below assumes want re-run method.

once catch exception, if create connection have recursively call original method.

so, thing should scare infinite recursion. if make check combat fine.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -