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
Post a Comment