Background Image
응용개발
2009.04.15 04:16

jdbc에서 질의 플랜정보 보는 방법

조회 수 15840 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
JDBC 프로그램에서 질의 플랜정보 보는 방법

CUBRID는  JDBC 프로그램에서 질의 플랜을 출력해주는 메소드를 제공한다.
cubrid.conf 설정

플랜이 출력되려면 CUBRID 설정파일인 $CUBRID/conf/cubrid.conf에 optimization_level=513을 추가하고 DB 서버를 재시작하여야 한다.

# Enable Java Stored Procedure
java_stored_procedure=no
optimization_level=513

간단 예제
다음은 질의 플랜을 화면에 출력하는 간단 예제이다.

import java.sql.*;
import cubrid.jdbc.driver.*; //CUBRIDStatement를 사용하기 위해 import 해야 함.
public class getQueryplan{
        public static void main(String arg[]) throws Exception {
                Connection        conn = null;
                ResultSet         rs = null;
                PreparedStatement  pstmt = null;               
                try {
                        Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
                        conn = DriverManager.getConnection("jdbc:cubrid:localhost:53000:demodb:::","","");
                        conn.setAutoCommit(false); //플랜 정보를 가져오기 위해서는 auto commit을 false로 설정해야 함.
                        String sql = "select host_nation from olympic where host_year = ?";
                        pstmt = conn.prepareStatement(sql);
                        pstmt.setInt(1, 2004);
                        ((CUBRIDStatement)pstmt).setQueryInfo(true);                
                        rs = pstmt.executeQuery();
                        String plan = ((CUBRIDStatement)pstmt).getQueryplan(); // 수행한 질의 플랜 정보를 가져오는 메소드.
                        while(rs.next())
                            System.out.println("host_nation : " + rs.getString(1));
                        conn.commit();
                        System.out.println("plan : " + plan);               
                }catch ( SQLException e ) {
                        e.printStackTrace();
                }catch ( Exception e ) {
                        e.printStackTrace();
                }finally {
                        if (rs != null) rs.close();
                        if (pstmt != null) pstmt.close();
                        if (conn != null) conn.close();
                }
        }
}




  1. jdbc에서 질의 플랜정보 보는 방법

    Date2009.04.15 Category응용개발 By손승일 Views15840
    Read More
  2. jdbc에서 bit 데이터 타입 사용하기

    Date2009.04.11 Category응용개발 By손승일 Views15013
    Read More
  3. PHP에서 prepared statement 사용시 BIND 관련 팁

    Date2009.06.30 Category응용개발 ByPrototype Views14843
    Read More
  4. 전체 레코드 개수 확인하는 SP

    Date2015.05.07 Category응용개발 By김승훈 Views14728
    Read More
  5. cubrid-php module r2.2 이상 버젼에서 configure시에 주의사항

    Date2010.07.20 Category응용개발 Byseongjoon Views14007
    Read More
  6. PHP 프로그램을 작성할때 주의할 점

    Date2009.07.01 Category응용개발 ByPrototype Views13728
    Read More
  7. CUBRID에서 SQL힌트와 주석을 쓸 때 순서.

    Date2012.01.11 Category응용개발 Bycubebridge Views13324
    Read More
  8. 용량이 큰 데이터를 질의로 저장하는 방법

    Date2009.11.26 Category응용개발 By남재우 Views12117
    Read More
  9. maven에서 CUBRID JDBC Driver 추가하기

    Date2015.12.09 Category응용개발 By김승훈 Views8946
    Read More
  10. JAVA SP 사용 시 로그 처리 방법

    Date2015.06.03 Category응용개발 By손승일 Views8574
    Read More
  11. CUBRID HA 제약 사항 및 확인 방법

    Date2015.12.29 Category응용개발 By손승일 Views5305
    Read More
  12. Windows 환경에서 JAVA SP 사용 utf-8 한글 깨짐 해결

    Date2016.07.01 Category응용개발 By손승일 Views4592
    Read More
  13. CUBRID DB에서 critical section 정보 출력하기

    Date2015.12.31 Category응용개발 By주현 Views4591
    Read More
  14. Windows에서 32bit 버전의 PHP 설치 후 CUBRID와 연동 실패 시 해결 방법

    Date2016.03.28 Category응용개발 By진우진 Views4523
    Read More
  15. CUBRID PHP 드라이버 빌드와 연동방법

    Date2018.03.07 Category응용개발 By정만영 Views3767
    Read More
  16. CUBRID 와 DBCP의 관계

    Date2016.12.14 Category응용개발 By엄기호 Views2797
    Read More
Board Pagination Prev 1 2 3 Next
/ 3

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales