목록Programming Language (1)
Be an Overachiever
AutoCloseable interface
AutoCloseable interface를 통해 코드를 깔끔하게 리팩토링 해보자. JDBC를 사용할 경우 마지막에 connection 객체를 close() 처리를 해주어야한다. 이 경우 주로 finally 문에서 close() 처리를 한다. 12345678910Connection connection = null; try { connection = pool.getConnection(); // do something} catch (ConnectionException e) { LOGGER.error("Connection Exception 발생");} finally { connection.close();}Colored by Color Scriptercs 하지만 만약 pool에서 connection 객체를 가져..
Programming Language/Java
2018. 8. 21. 22:53