본문 바로가기

[javascript] location.href? location.href = 이것 A -> B -> C B -> C로 이동할때 location.href를 쓰면 C에서 B로 이동한다. 대신 location.replace()를 쓰면 C에서 A로 이동한다. 이와 같이 동작하는 것을 찾아보자 1. history.go(-1); 2. 3. location.href 4. location.replace(); 5... 더찾아보고 어떻게 동작하는지 정리해두기 더보기
[php] strpos, substr ... 아 헷갈려 $r1str = "01-23"; $pos = strpos($r1str, "-"); $first = substr($r1str,0,$pos); $last = substr($r1str,$pos); 출력결과는 $pos = 2 $first = 01 $last = -23 더보기
[java] hash/tree set/map/table ... 정리한번 쫙 해놓자 더보기
[java/jsp/jdbc] PreparedStatement 와 close() String Query = "SELECT * FROM table"; PreparedStatement pstmt = conn.prepareStatement(query); ResultSet rs = pstmt.executeQuery(); ... Query = "SELECT COUNT(*) FROM table"; pstmt = conn.prepareStatement(query); rs = pstmt.executeQuery(); ... 위와 같이 pstmt를 하나 선언하고, 재사용한다고 하더라고 반드기 다음 pstmt를 재사용하기 전에 close()를 할 것. 이와 마찬가지로 rs도... 그리고 참고 : http://cafe.daum.net/MobileCreator/Lkga/103?docid=nDQL|Lkga|.. 더보기
[jdbc] php의 mysql_num_rows() 를 자바에서 쓰기 php에서는 디비로 쿼리를 보내고 결과의 개수(행의 개수)를 mysql_num_rows()라는 함수로 쉽게 구할 수 있다. $query = "SELECT a FROM table WHERE table.no=1"; $result = mysql_query($query, $connect); $cnt = mysql_num_rows($result); 이것을 jdbc에서는 (있는지 모르겠지만) 함수로는 없다. ResultSet 클래스의 getFetchSize()라는 함수가 있지만, fetch된 결과의 size를 구하는 것이 아니라. 한번에 얼마만큼의 데이터를 가져올 것인지 클래스에 셋팅된 값을 리턴하는 것이다. 따라서, 꼼수로 ResultSet의 커서를 마지막으로 옮기고, 그곳의 row number(행번호)를 얻어오.. 더보기