인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

재스미니's profile image
재스미니

asked

Java Spring Framework (renewed ver.) - Course for new programmers

Connection pool

질문있습니다. 커넥션풀

Written on

·

161

0

간단하게 테스트하려고 소스짯는데요. 맞는지 모르겠네요.

스프링컨테이너XML파일에 ComboPooledDataSource 정의하였구요.

@Autowired으로 자동 주입해서 썻습니다..

정상적으로 실행은 되는데요. 여기서 자원을 따로 해제할 필요는 없나요?

@Autowired

ComboPooledDataSource db;

@RequestMapping(value = "/leejaemin", method = RequestMethod.GET)

public String leejaemin() {

Connection conn = null;

ResultSet rs= null;

PreparedStatement pstmt =null;

try {

conn = db.getConnection();

String sql = "select * from member";

pstmt = conn.prepareStatement(sql);

rs = pstmt.executeQuery();

            while (rs.next()) {

                String gameCode = rs.getString("MEMID");

                System.out.println(gameCode);

            }

}

catch (SQLException e) {

            System.out.println(e.getMessage());

        } finally {

        }

return "/index";

}

}

javaspring

Answer

This question is waiting for answers
Be the first to answer!
재스미니's profile image
재스미니

asked

Ask a question