JDBC

GOLDILOCKS JDBC 개요

GOLDILOCKS JDBC 소개

GOLDILOCKS는 TCP/ IP 연결을 기반으로 한 표준 JDBC 4.0을 준수 (일부 기능 제외)하는 GOLDILOCKS JDBC 드라이버를 제공한다. 사용자는 GOLDILOCKS JDBC 드라이버를 이용하여 Java 프로그램 내에서 GOLDILOCKS와 접속하여 각종 트랜잭션 기능 및 데이터 조회 기능을 사용할 수 있다. GOLDILOCKS JDBC 드라이버는 JDK 1.6 기반으로 작성되고 구축되었기 때문에 JDBC 4.0의 기능을 지원한다. $GOLDILOCKS_HOME/lib/goldilocks6.jar 파일을 class path에 추가하여 드라이버를 사용할 수 있다.

goldilocks 다음의 숫자는 JDK 버전을 의미한다. 자세한 내용은 버전 및 지원 여부를 참조한다.

GOLDILOCKS JDBC는 JDBC 표준 스펙을 대부분 준수하고 있으며 일부 고유한 기능을 제공하기 위해 표준 API가 아닌 method와 클래스도 지원한다. 비표준 method에 대해서는 JDBC API References 각 클래스 API나 추가 타입 사용을 참조한다.

특징

GOLDILOCKS JDBC는 순수 Java로만 구현된 JDBC Type-4 유형이다. 추가적인 라이브러리 없이 jar 파일만으로 JDBC 드라이버를 사용할 수 있다. 뿐만 아니라 JDBC-ODBC bridge 유형보다 빠르고 안정적이며 native API를 사용한 Type-2보다 이식성 (portability)이 좋다.

GOLDILOCKS JDBC는 JDBC 표준을 준수하므로 여타의 JDBC 프로그램을 거의 변경하지 않고 재활용할 수 있다. Connection을 얻는 방법부터 각종 statement, ResultSet 기능들을 수정없이 사용할 수 있다. 단, connection URL과 프로퍼티 이름, 로딩할 드라이버 클래스 이름은 GOLDILOCKS에 맞게 변경해야 한다. 그리고 표준에 없는 기능과 타입들은 별도의 클래스와 method API로 사용할 수 있다.

GOLDILOCKS JDBC 드라이버는 세 개의 파일 (goldilocks8.jar, goldilocks7.jar, goldilocks6.jar)을 지원하므로 사용자는 Java 실행 환경에 맞는 파일을 선택하여 사용할 수 있다. 각각의 jar 파일은 JDK 1.8, JDK 1.7, JDK 1.6을 기반으로 제작, 구축되었기 때문에 JDBC 4.2, JDBC 4.1, JDBC 4.0 스펙을 따른다.

서버와 JDBC 드라이버와의 호환성은 프로토콜 버전을 참조한다. 서버가 JDBC 드라이버보다 프로토콜 버전이 높을 경우에 접속할 수 있다.

JDBC connection 객체는 생성 비용이 비싼 자원이다. 따라서 JDBC 표준에는 이를 풀링할 수 있는 체계를 정의했으며 그것을 인터페이스로 만든 것이 ConnectionPoolDataSource와 PooledConnection이다. GOLDILOCKS JDBC는 이 인터페이스를 구현하여 제3자의 미들웨어 제품에서 풀링 기능을 사용할 수 있도록 하는 기반을 제공한다.

글로벌 트랜잭션 표준인 XA 인터페이스를 구현하여 사용자가 글로벌 트랜잭션 작업을 할 수 있도록 한다. JDBC 인터페이스인 XAResource를 사용하여 각종 XA 기능을 표준에 맞게 수행할 수 있다.

GOLDILOCKS는 JDBC 표준에서 제공하지 않는 데이터 타입을 사용한다. 예를 들어 interval 관련 타입과 timestamp with time zone과 같이 time zone 정보를 가지는 타입들이 있다. 이들 타입들을 데이터베이스에 삽입하거나 가져올 수 있는 방법들을 드라이버가 제공한다.

타 JDBC 드라이버들은 ResultSet 스크롤을 위해 row set을 드라이버 내에서 caching하는 방법을 취하여, client 응용 프로그램이 과도하게 메모리를 많이 사용하는 경우가 있다. 예를 들어 scroll insensitive로 커서를 열어 마지막 row까지 fetch하게 되면 모든 row들을 드라이버 내에 caching하게 되는데 이 때 전체 테이블이 client 메모리에 상주하게 되므로 out of memory 에러가 발생할 수도 있고, 과도하게 client 메모리 리소스를 소모하게 된다.

하지만 GOLDILOCKS는 서버 내에 커서 스크롤 기능이 있기 때문에 client가 가볍고, 빠르고 안정적인 성능을 낼 수 있다.

타 JDBC 드라이버들에 비해 row 정보를 유지하는 메모리를 최소화하고, 되도록 Java 객체를 사용하지 않기 때문에 많은 row들을 탐색할 경우에도 garbage collection 작업을 피할 수 있으며 적은 메모리를 사용하도록 하여 빠르고 안정적으로 테이블을 스캔할 수 있다.

JDBC 표준의 DatabaseMetaData 인터페이스를 충실하고 정확하게 구현했기 때문에 다양한 데이터베이스 툴과 쉽게 연계할 수 있다. 뿐만 아니라 각종 시스템 view를 통해 데이터베이스 메타 정보들을 조회할 수 있어 사용성이 높아졌다.

문제가 발생했을 때 뿐만 아니라 평상시에도 JDBC API 콜이나 네트워크 사용 상황을 모니터링 할 수 있도록 각종 logging 기능을 제공한다. Connection URL에 로깅 관련 기능을 명세하면 콘솔이나 파일 등으로 해당 내용의 기록을 남길 수 있다. 로깅에는 JDBC method call 기록에 대한 로깅, 프로토콜 송수신에 대한 로깅, 사용한 SQL 문에 대한 로깅, global connection 사용에 대한 로깅, 이 네 가지가 있다.

GOLDILOCKS 서버와의 연결에 실패하거나 execution 할 때 연결이 끊어지면 미리 등록된 대체 서버에 자동으로 다시 접속하여 기존 connection을 계속해서 사용할 수 있도록 JDBC driver 레벨의 connection failover를 지원한다. 사용자는 connection이 끊겼을 때를 대비한 별도의 예외 처리없이 기존의 JDBC 프로그램으로 connection failover 기능을 사용할 수 있다.

TCP/ IP 기반의 연결 이외에 서버와 같은 프로세스로 연동할 수 있는 direct attach 방식의 연결도 할 수 있다. ODBC 연결이 direct attach, Client/ Server 방식을 모두 지원하듯이 GOLDILOCKS JDBC driver도 두 가지 연결 방법을 모두 제공한다. Direct attach로 연결된 JDBC 프로그램은 TCP/ IP 통신을 하지 않고 직접 서버 프로세스에 연동되어 jvm 안에서 서버 기능을 사용할 수 있다. TCP/ IP로 연결한 JDBC 프로그램보다 두 배 이상의 성능을 낼 수 있다.

버전 및 지원 여부

GOLDILOCKS JDBC 버전 체계

goldilocks6.jar 파일에 대해 다음처럼 실행하면 GOLDILOCKS JDBC 버전 정보를 볼 수 있다.

shell>java -jar goldilocks6.jar

 GOLDILOCKS JDBC Driver 1.1 Procotol-2.5.2, JDBC4.0 compiled with JDK1.6

위 예제는 현재 GOLDILOCKS JDBC 드라이버 버전이 1.1이고, 프로토콜 버전은 2.5.2, 그리고 이 드라이버가 준수하는 JDBC 표준 버전은 4.0이며 JDK 1.6에서 구축되었다는 정보를 담고 있다. 드라이버 버전은 GOLDILOCKS 제품 버전과는 별개로 표시되고 기능이 보강될 때마다 올라간다. JDBC 드라이버 버전에 대한 자세한 내용은 DatabaseMetaData의 getDriverMajorVersion, getDriverMinorVersion, getDriverVersion을 참조한다.

프로토콜 버전은 서버와의 호환성 여부를 결정하며 드라이버는 서버의 프로토콜 버전과 같거나 더 낮을 때 서버에 연동될 수 있다. 즉, 서버는 하위 프로토콜 버전의 모든 client API를 지원한다.

goldilocks6.jar는 JDBC 4.0 표준을 준수하며 JDK 1.6에서 구축되었다. goldilocks7.jar는 JDBC 4.1 표준을 준수하며 JDK 1.7에서 구축되었다. goldilocks8.jar는 JDBC 4.2 표준을 준수하며 JDK 1.8에서 구축되었다. 따라서 사용자 Java 환경이 JDK 1.8 이상일 경우에는 goldilocks8.jar를 사용하면 된다. 다만 JDK 1.9 이상의 Java를 사용할 경우, goldilocks8.jar는 사용할 수 있지만 JDBC 4.3의 API나 클래스들은 사용할 수 없다.

사용 예

Class Path 설정

GOLDILOCKS JDBC 드라이버를 사용하려면 CLASSPATH 설정해야 한다.

export CLASSPATH=.:$GOLDILOCKS_HOME/lib/goldilocks6.jar

또는 사용자의 Java 실행환경에 맞는 jar 파일을 path에 추가해도 된다.

드라이버 클래스 로딩

드라이버 클래스는 다음과 같이 로딩할 수 있다.

Class.forName("sunje.goldilocks.jdbc.GoldilocksDriver");

위 예는 전통적인 JDBC 사용 방법으로써 해당 드라이버 클래스를 동적으로 로딩하여 DriverManager에 등록하게 한 다음 연결을 얻는다. 요즘은 DataSource를 통해 연결을 얻는 방법을 더 많이 사용하는데 이에 대해서는 JDBC API References의 해당 클래스를 참조한다.

Connection 얻기

Connection을 얻으려면 다음과 같이 코드를 작성한다.

Connection con = DriverManager.getConnection(
    "jdbc:goldilocks://127.0.0.1:22581/test", "TEST", "test");

GOLDILOCKS JDBC를 사용하기 위한 접속 URL은 "jdbc:goldilocks:"로 시작해야 한다. 그 다음은 서버의 IP와 port 번호이며 URL의 마지막 부분 "/test"는 DB 이름이다. 현재 GOLDILOCKS는 다중 DB를 지원하지 않으므로 DB 이름을 특별히 체크하지는 않는다. 사용자가 접속한 URL은 DatabaseMetaData.getURL()을 통해서 다시 얻을 수 있다.

IP를 0.0.0.0으로, 포트를 0으로 설정하면 Direct Attach (D/A) 모드로 접속한다. 혹은 ip:port 대신 da라는 접속 프로토콜을 사용해도 된다. 즉 다음 두 URL 모두 D/A 모드로 접속하게 한다.

"jdbc:goldilocks://0.0.0.0:0/test"
"jdbc:goldilocks:da/test"

Username과 password는 각각 데이터베이스의 계정과 암호를 사용해야 한다.

Statement와 ResultSet 사용

Statement와 ResultSet은 다른 JDBC 프로그램과 동일하게 사용하면 된다.

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT NAME, ADDRESS FROM EMP");
while (rs.next())
{
    System.out.println("name = " + rs.getString(1));
    System.out.println("address = " + rs.getString(2));
}
rs.close();
stmt.close();

기능 명세

연결

DriverManager를 이용한 연결

Connection을 얻는 전통적인 방법은 DriverManager를 사용하는 것이다.

Connection con = DriverManager.getConnection(url_string, user_name, password);

url_string에는 다음과 같은 세가지 유형이 있다.

jdbc:goldilocks://[ip address]:[port_no]/[db_name]
jdbc:goldilocks:da/[db_name]
jdbc:goldilocks:locator//[ip address]:[port_no][, [ip address]:[port_no] ]*/[db_name]

IP address에는 호스트 이름, IPv4, IPv6 모두 사용 가능하며, port_no에는 설정된 포트 번호를 명시하면 된다. db_name은 현재 접속에 사용되지 않기 때문에 어떤 이름이든 설정할 수 있지만 생략할 수는 없다. 다음은 예제 URL이다.

String url_string = "jdbc:goldilocks://localhost:22581/test";
String url_string = "jdbc:goldilocks://127.0.0.1:22581/test";
String url_string = "jdbc:goldilocks://[::1]:22581/test";

IP "0.0.0.0"과 포트 0은 D/A 접속을 위한 특별한 주소로 사용된다. D/A 모드에 대한 자세한 내용은 Direct Attach 모드 접속을 참조한다.

user_name과 password는 GOLDILOCKS 계정을 의미한다.

위의 getConnection() method 외에 각종 property를 설정하기 위해 다음 method를 사용한다.

Properties prop = new Properties();
prop.setProperty("user", user_name);
prop.setProperty("password", password);
Connection con = DriverManager.getConnection(url_string, prop);

glocator로부터 서버의 접속 정보를 얻기 위해 연결 프로퍼티를 대신하여 url_string에 locator 키워드를 추가하여 사용할 수 있다. 이 때 ip address와 port_no는 glocator의 접속 정보로 간주한다. 다음은 연결 구문에 locator 키워드를 사용하는 예이다.

String url_string = "jdbc:goldilocks:locator//127.0.0.1:42581,127.0.0.1:42582/test?locator_service=S1";

처음 접속 정보 127.0.0.1:42581은 glocator의 접속 정보이고 이후의 접속 정보는 127.0.0.1:42582처럼ALTERNATE_LOCATORS 프로퍼티로 처리된다.

다음은 위의 url_string과 같은 의미의 프로퍼티 설정이다.

String url_strng = "jdbc:goldilocks://0.0.0.0:0/test";
Properties prop = new Properties();
prop.setProperty("locator_host", "127.0.0.1");
prop.setProperty("locator_port", "42581");
prop.setProperty("alternate_locators", "127.0.0.1:42582");
prop.setProperty("locator_service", "S1");
Connection con = DriverManager.getConnection(url_string, prop);

접속에 사용할 수 있는 프로퍼티 목록은 GOLDILOCKSDriver의 getPropertyInfo() method를 통해 확인할 수 있다. 자세한 내용은 The internal link is invalid.를 참조한다.

DriverManager를 사용하면 생성되는 connection 객체의 login timeout과 logger는 DriverManager에 등록된 값을 사용한다. 즉, 이 connection 객체로부터 생성되는 모든 JDBC 인터페이스들이 사용하는 logger는 저 logger이다. 따라서 connection 객체마다 개별 logger를 가질 수 없다.

DataSource를 이용한 연결

JDBC 표준은 과거의 DriverManager보다는 DataSource를 사용할 것을 더 권장한다. DataSource는 어떤 data source에 접근할 수 있도록 하는 단일한 인터페이스이며, 각종 data source에 관계되는 설정 값들을 개별적으로 설정할 수 있으며, DataSource 객체 자체를 원격으로 전송할 수도 있기 때문이다.

다음과 같이 DataSource를 통해 connection 객체를 얻을 수 있다.

import sunje.goldilocks.jdbc.GoldilocksDataSource;

GoldilocksDataSource ds = new GoldilocksDataSource();
ds.setServerName("127.0.0.1");
ds.setPortNumber(22581);
ds.setDatabaseName("test");
ds.setUser("TEST");
ds.setPassword("test");
Connection con = ds.getConnection();

이처럼 DataSource 객체를 생성하기 위해서는 GoldilocksDataSource 클래스를 사용해야 한다.

그 다음 각종 연결 정보는 DataSource 표준 API가 아닌 setter method를 사용해야 하는데, 자세한 설명은 DataSource를 참조한다.

DriverManager를 이용할 때는 login timeout과 logger를 글로벌하게 설정했어야 했지만, DataSource는 login timeout과 logger를 개별적으로 설정할 수 있다.

ds.setLoginTimeout(10);
ds.setLogWriter(out);

미들웨어 연동

Weblogic, JBoss와 같은 미들웨어와 연동하려면 XADataSource, ConnectionPoolDataSource 인터페이스를 구현한 클래스 이름을 알아야 한다. GOLDILOCKS에서는 sunje.goldilocks.jdbc 패키지에 GoldilocksXADataSource, GoldilocksConnectionPoolDataSource를 제공한다. 이 두 클래스 모두 GoldilocksDataSource와 마찬가지로 각종 setter method를 제공한다.

import sunje.goldilocks.jdbc.GoldilocksXADataSource;

GoldilocksXADataSource ds = new GoldilocksXADataSource();
ds.setServerName("127.0.0.1");
ds.setPortNumber(22581);
ds.setDatabaseName("test");
ds.setUser("TEST");
ds.setPassword("test");
XAConnection con = ds.getXAConnection();

연결 프로퍼티

연결 프로퍼티

이름

필수/선택

유효값

설명

alternate_servers

선택

IP:PORT[,IP:PORT]+

Failover를 위한 대체 서버 목록이다. 콤마 (,)로 구분한다.

alternate_locators

선택

IP:PORT[,IP:PORT]+

glocator의 대체 목록이다.

batch_count

선택

Any integer

한 번의 프로토콜 송수신으로 처리할 수 있는 batch job 개수이다. 기본값은 1000이다. 이 값이 너무 작으면 배치를 처리할 때 네트워크 송수신이 잦아져 성능이 저하될 수 있고, 너무 크면 세션이 execution result들을 쌓아놔야 하기 때문에 서버 메모리가 증가될 수 있다.

connection_retry_count

선택

Any integer

연결할 때의 재시도 횟수를 저장한다. 기본값은 0이고 재시도하지 않는다.

connection_retry_delay

선택

Any integer

연결을 재시도할 때 재시도 하기 전의 delay를 초 단위로 지정한다. 기본값은 3이다.

date_format

선택

Any string

드라이버 내부에서 date와 string 사이의 변환 작업에 사용되는 문자 포맷이다.

da_buffer_size

선택

Any integer

Direct attach 모드로 접속했을 경우 fetch, bind 할 때 데이터를 주고 받는 버퍼의 크기를 지정한다. 기본값은 100000이다.

decoding_replacement

선택

Any string

바이트 배열을 string으로 decoding 할 때, decoding할 수 없는 바이트 값을 대체할 문자이다. 기본값은 ?이다.

failover_granularity

선택

{"0", "1", "2"}

Failover 성공 여부를 판단한다. non-atomic(0), atomic(1), 2는 아직 지원하지 않는다. Failover 도중에 기존 prepared statement들에 대해 prepare 과정에서 에러가 발생할 경우 0은 failover를 계속 수행하고 1은 failover 실패를 결정한다. 기본값은 0이다.

failover_type

선택

{"connection", "session"}

Failover 유형을 결정한다.

  • Connection: 서버에 접속할 때만 failover를 사용한다.

  • Session: 서버에 접속할 때 뿐만 아니라 execution 등 서버와 통신하는 모든 경우에 failover를 사용한다. 기본값은 connection이다.

format_grammar

선택

{"db", "java"}

date_format과 같은 속성 문자열이 GOLDILOCKS 문법인지, Java의 SimpleDateFormat에 사용되는 문법인지를 결정한다. 기본값은 db이다.

global_connection_log

선택

boolean

global connection 로깅을 할 것인지 여부이다. 기본값은 false 이다.

global_logger

선택

{"console"}

로깅 대상을 지정한다.

현재는 console만 가능한다. 가장 먼저 지정한 것만 유효하다.

home_dir

선택

Any string

Cluster server의 home directory를 지정한다. 기본값은 null이다.

include_synonyms

선택

boolean

DatabaseMetaData.getColumns()에 synonym 객체를 포함할지 여부이다. 기본값은 false 이다.

keep_alive

선택

boolean

Connection의 socket 속성을 keep_alive로 설정할지 여부이다. 이 속성을 부여하면 TCP socket 내부에서 주기적으로 ack를 주고받으며 서로 연결된 상태를 유지한다. 즉, 랜선 에러를 감지하여 연결을 강제로 끊기게 할 수 있다. 기본값은 false 이다.

locality_aware_transaction

선택

boolean

GLOBAL CONNECTION 사용 여부이다. true로 설정하면 GLOBAL CONNECTION을 사용한다. 기본값은 false이다.

locality_group_policy

선택

{"0", "1", "2"}

GLOBAL CONNECTION을 사용할 때 선택할 수 있는 그룹이 없거나 둘 이상의 그룹을 선택할 수 있을 경우, 그룹 선택 방법을 설정한다.

  • 0: 임의로 선택한다.

  • 1: LOCALITY_GROUP_PATH 설정에 존재하는 그룹을 순서대로 선택한다. LOCALITY_GROUP_PATH에 있는 모든 그룹을 사용할 수 없는 경우에는 임의의 그룹을 선택한다.

  • 2: 순서대로 선택한다. 매번 드라이버에 연결된 그룹 순서대로 선택한다.

locality_group_path

선택

Group name list

GLOBAL CONNECTION을 사용할 때 선택할 수 있는 그룹이 한 개가 아니었을 때 선택한 그룹의 목록을 지정한다. 각 그룹은 콤마 (,)로 구분한다.

예: G1,G2,G3

locality_member_policy

선택

{"0","1","2","3","4"}

GLOBAL CONNECTION을 사용할 때 선택된 그룹 내의 멤버를 선택하는 방법을 결정한다.

  • 0: DML : MASTER / SELECT : MASTER

  • 1: DML : ANY / SELECT : ANY

  • 2: DML : MASTER / SELECT : ANY

  • 3: DML : MASTER / SELECT : SLAVE

  • 4: LOCALITY_MEMBER_PATH 설정에 존재하는 멤버를 순서대로 선택한다. LOCALITY_MEMBER_PATH에 존재하는 모든 멤버들을 사용할 수 없는 경우에는 선택된 그룹의 MASTER를 선택한다.

locality_member_path

선택

Member name list

GLOBAL CONNECTION을 사용할 때 선택된 그룹에서 사용할 멤버들의 목록을 지정한다. 각 멤버는 콤마 (,)로 구분한다.

예: G1N1,G2N1,G3N1,G1N2,G2N2,G3N2

locality_on_demand

선택

boolean

GLOBAL CONNECTION을 사용하면서 연결이 필요한 멤버가 있을 경우 해당 멤버에 접속한다. 기본값은 false이다.

  • false: 처음부터 모든 멤버에 접속한다.

  • true: 필요한 경우 해당 멤버에 접속한다.

locator_connection_timeout

선택

Any integer

glocator로부터 패킷을 받을 때까지 대기하는 시간이다.

locator_file

선택

Any string

Location file이다.

locator_host

선택

IP address

glocator의 host address이다.

locator_port

선택

Port no

glocator의 port이다.

locator_service

선택

Any string

서버 접속 정보를 얻기 위한 service 이름이다.

login_timeout

선택

Any integer

서버와 연결할 때 socket의 timeout 시간 (초)을 설정한다. 기본값은 0으로 무한대기한다.

lzeros

선택

Any integer

Numeric을 문자열로 표현할 때 소수점 다음 0의 개수가 이 값을 넘어가면 exponent 표기법으로 표현된다. 기본값은 15이다.

new_password

선택

Any string

old_password 속성과 함께 사용하여 계정 암호를 바꿀 수 있다.

old_password

선택

Any string

new_password 속성과 함께 사용하여 계정 암호를 바꿀 수 있다.

packet_compression_threshold

선택

Any integer

서버로 보낼 통신 데이터의 크기가 packet_compression_threshold 보다 클 경우, 통신 데이터를 압축한다. 속성값의 범위는 32 ~ 2113929216 이다.

password

필수

Any string

사용자 계정 암호이다.

prefer_ipv6

선택

boolean

호스트 이름의 IP 주소 중에 IPv6를 우선시할지 여부이다. 기본값은 false 이다.

program

선택

Any string

프로그램에 대한 설명이다.

protocol_log

선택

boolean

프로토콜 송수신 로깅을 할 것인지 여부이다. 기본값은 false 이다.

query_log

선택

boolean

쿼리 로깅을 할 것인지 여부이다. 기본값은 false 이다.

role

선택

{"", "SYSDBA",

"ADMIN"}

계정 롤을 지정한다. 기본값은 ""이다.

session_type

선택

{"1", "2", "3"} 또는

{"dedicate", "shared", "default"}

Dedicated/ shared/ default 중 하나이다.

(Default를 선택할 경우, DB에서 선택된다.)

statement_pool_on

선택

boolean

Statement pool을 활성화한다. 기본값은 false 이다.

statement_pool_size

선택

Any integer

Statement pool의 크기를 설정한다.

time_format

선택

Any string

드라이버 내부에서 time과 string 사이의 변환 작업에 사용되는 문자 포맷이다.

tcp_nodelay

선택

boolean

Connection의 socket에 TCP_NODELAY(Nagle's Algorithm) 속성을 설정한다. 기본값은 true 이다.

timestamp_format

선택

Any string

드라이버 내부에서 timestamp와 string 사이의 변환 작업에 사용되는 문자 포맷이다.

time_with_time_zone_format

선택

Any string

드라이버 내부에서 time with timezone과 string 사이의 변환 작업에 사용되는 문자 포맷이다.

timestamp_with_time_zone_format

선택

Any string

드라이버 내부에서 timestamp with timezone과 string 사이의 변환 작업에 사용되는 문자 포맷이다.

trace_log

선택

boolean

트레이스 로깅을 할 것인지 여부이다. 기본값은 false 이다.

tzeros

선택

Any integer

Numeric을 문자열로 표현할 때 자릿수 0의 개수가 이 값을 넘어가면 exponent 표기법으로 표현된다. 기본값은 15이다.

user

필수

Any string

사용자 계정 이름이다.

use_global_session

선택

boolean

GLOBAL SESSION 사용 여부이다. 기본값은 false 이다.

use_targettype

선택

{"0", "1","2"}

통신을 통해 column 타입을 수신할 경우, 같이 수신할 정보이다.

  • 0: none

  • 1: name

  • 2: all

데이터 조작

Statement를 이용한 데이터 조작

Statement 객체를 사용하여 각종 SQL 문을 실행할 수 있다. 다음과 같이 connection 객체로부터 statement 객체를 얻을 수 있다.

Connection con = DriverManager.getConnection(...);
Statement stmt = con.createStatement();

이렇게 생성된 statement 객체의 execute method와 executeUpdate method를 사용하여 각종 DML 문이나 DDL 문을 수행할 수 있다.

stmt.executeUpdate("create table emp ( id varchar(20), name varchar(30), age integer )");
stmt.executeUpdate("insert into emp values ('1234560000', '김연아', 24)");
int updated = stmt.executeUpdate("delete from emp where age > " + age);

execute와 executeUpdate의 차이점은 오직 반환값 뿐이다. execute는 수행한 SQL 문이 ResultSet을 반환하는지 여부를, executeUpdate는 갱신이 반영된 row의 개수를 각각 반환한다. execute는 DML이나 SELECT 구문에 모두 사용할 수 있지만 executeUpdate를 SELECT 문에 사용하면 SQLException이 발생한다.

Statement로 SQL 문을 실행하는 것을 direct-execution이라고 한다. Direct-execution은 SQL 문에 대한 prepare 작업 (파싱, 검증 (validation), 최적화 (optimization) 작업)과 실행 (execution)을 한 번에 수행하는 방법이다. 이에 반해 prepare-execution은 prepare 작업을 한 번 해두고, execution을 반복 수행하는 방법이다. Direct-execution을 한 번 수행할 때마다 prepare, execution 작업이 발생하기 때문에 동일한 SQL 문을 반복적으로 수행해야 할 경우 prepare-execution이 더 효율적이다.

PreparedStatement를 이용한 데이터 조작

JDBC 표준은 데이터 조작을 위해 parameter를 사용할 수 있는 PreparedStatement 인터페이스를 제공하여 사용자가 보다 효율적으로 실행할 수 있도록 한다. 뿐만 아니라 PreparedStatement는 반복적인 실행에 대해 SQL 문 prepare 작업을 한 번만 하기 때문에 빠르게 수행할 수 있다.

Connection con = DriverManager.getConnection(...);
PreparedStatement pstmt = con.prepareStatement(
  "insert into emp values (?, ?, ?)");
pstmt.setString(1, "55544123000");
pstmt.setString(2, "김길동");
pstmt.setInt(3, 32);
pstmt.executeUpdate();
pstmt.setString(1, "1357924680");
pstmt.setString(2, "고둘리");
pstmt.setInt(3, 41);
pstmt.executeUpdate();

라인 2 ~ 3처럼 SQL 문을 prepare 해놓은 후에 데이터를 바인딩하고 실행한다. 한 번 prepare된 PreparedStatement는 계속해서 바인딩과 실행을 반복 수행할 수 있다.

만약 바인딩을 생략하고 execute()를 수행하면 이전에 바인딩 했던 값들이 사용된다.

pstmt.setString(1, "333555777000");
pstmt.setString(2, "강철규");
pstmt.setInt(3, 55);
pstmt.executeUpdate();
pstmt.setString(1, "245778884440");
pstmt.executeUpdate();

이처럼 라인 6에서 2, 3 번째 파라미터에 값을 바인딩하지 않고 바로 실행하면 이전에 바인딩 된 값인 "강철규"와 55가 사용된다. 만약 이전에 바인딩 된 값이 없을 경우, SQLException이 발생한다.

바인딩 된 값들을 모두 제거하려면 clearParameters()를 사용한다.

pstmt.setString(1, "333555777000");
pstmt.setString(2, "강철규");
pstmt.setInt(3, 55);
pstmt.executeUpdate();
pstmt.clearParameters();
pstmt.setString(1, "245778884440");
pstmt.executeUpdate();

이와 같이 라인 5에서 parameter들을 제거한 후, 첫 번째 parameter에만 값을 바인딩하고 실행하면 (라인 7) SQLException이 발생한다.

PreparedStatement를 사용하는 주된 이유는 다양한 타입의 데이터를 바인딩 할 수 있기 때문이다. Statement로는 값을 문자열로 표현할 수 밖에 없기 때문에 binary나 timestamp 같은 타입의 데이터를 입력하기에는 불편하다. 하지만 PreparedStatement로는 모든 타입으로 바인딩 할 수 있기 때문에 더 편리하다.

pstmt.setTimestamp(1,
  new Timestamp(Calendar.getInstance().getTimeInMillis()));
pstmt.setCharacterStream(2, new StringReader(BIG_STRING));
pstmt.setObject(3, someObj, Types.LONGVARCHAR);
pstmt.setObject(4, otherObj);

위의 예에서 1 ~ 2번 라인은 java.sql.Timestamp 객체를 바인딩한다. 바인딩 타입 (서버에 데이터가 전해질 때, 그 데이터의 GOLDILOCKS 타입)은 TIMESTAMP이다. 각종 setter method에 의해 결정되는 바인딩 타입에 대한 자세한 내용은 PreparedStatement의 해당 API를 참조한다.

라인 3은 reader 객체를 바인딩하는데, 내부적으로 LONG VARCHAR 타입으로 바인딩하게 된다.

라인 4는 Java object 타입의 객체를 바인딩하는데, 타입이 LONG VARCHAR라는 것을 명시적으로 알려준다. Types의 타입에 매핑되는 GOLDILOCKS 타입에 대한 자세한 내용은 SQL 타입 → GOLDILOCKS 타입을 참조한다.

라인 5는 Java object 타입을 그대로 바인딩하는데, 클래스 타입에 따라 해당되는 GOLDILOCKS 데이터 타입으로 바인딩된다. 클래스 타입과 GOLDILOCKS 데이터 타입 사이의 매핑에 대한 자세한 내용은 Java 객체 → GOLDILOCKS 타입을 참조한다.

Statement를 이용한 배치 실행

Statement의 addBatch()와 executeBatch()를 사용하여 서로 다른 SQL 문을 batch job 형태로 실행할 수 있다.

stmt.addBatch("insert into emp values ("12345", "Jake", 22)");
stmt.addBatch("insert into salary values ("12345", 5000)");
stmt.addBatch("update members set total_count=total_count+1 where age=22");
stmt.executeBatch();

이처럼 서로 다른 SQL 문을 하나의 executeBatch() method를 통해 수행할 수 있다. 하지만 이 method 호출을 통해 세 개의 구문 모두가 서버에서 수행된 결과를 모아 한 번의 프로토콜로 JDBC 드라이버에 전달하는 것은 아니다. 내부적으로 세 번의 프로토콜 전송과 서버에서의 실행, 결과 전송이라는 작업이 수행되는 것이다. 즉, 성능상 큰 이점을 가질 수 있는 것은 아니라는 점에 주의해야 한다.

executeBatch를 실행한 후 등록된 job들은 모두 지워진다.

실행 도중 에러가 발생해도 끝까지 등록된 job을 모두 수행한다. 에러 발생 유무는 반환된 int[] 형의 값을 참고하면 알 수 있다. 즉, int[]이 EXECUTE_FAILED 값을 가지면 그 job은 실패했다는 의미이다.

PreparedStatement를 이용한 배치 실행

PreparedStatement의 addBatch()와 executeBatch() method를 이용하여 좀 더 강력한 배치 실행을 수행할 수 있다.

PreparedStatement pstmt = con.prepareStatement("insert into emp values (?, ?, ?)");
pstmt.setString(1, "12345000");
pstmt.setString(2, "John");
pstmt.setInt(3, 33);
pstmt.addBatch();

pstmt.setString(1, "222333555");
pstmt.setString(2, "Henry");
pstmt.setInt(3, 24);
pstmt.addBatch();
int[] inserted = pstmt.executeBatch();

위의 예는 두 개의 row를 추가하는 과정이다. 두 개의 row를 구성할 값들을 addBatch()를 통해 바인드하고, 이후 executeBatch()를 호출하면 바인드 한 값과 execute에 대한 프로토콜이 서버로 전송되어 실행된다. 즉, executeBatch() 할 때만 통신하기 때문에 statement의 배치 실행보다 효율적이고 성능이 빠르다.

executeBatch()를 수행한 후엔 바인딩된 값들이 모두 삭제되기 때문에 executeBatch()을 다시 수행하려면 새로운 값을 다시 바인드해야 한다. 실행한 후에 등록된 job들을 지우기 위해 clearBatch()를 명시적으로 호출하지 않아도 된다.

실행하는 도중에 에러가 발생해도 등록된 job 모두를 끝까지 수행한다. 에러 발생 유무는 반환된 int[] 형의 값을 참고하여 확인할 수 있다. 즉, int[]이 EXECUTE_FAILED 값을 가지면 그 job은 실패했다는 의미이다.

GOLDILOCKS JDBC는 executeBatch() 외에 executeBatchAtomic() 이라는 별도의 method를 제공한다. executeBatch()는 서버에서 등록된 job의 개수만큼 실행하지만, executeBatchAtomic()은 등록된 job (바인딩된 값들)을 한 번에 실행하기 때문에 응답시간이 더 빠르다. 다만 atomic이라는 이름에서 알 수 있듯이 하나라도 실패하게 되면 전부 실패하게 된다. 따라서 반환되는 유형은 int[]형이 아니라 int이다.

...
int inserted = ((GoldilocksPreparedStatement)pstmt).executeBatchAtomic();

데이터 조회

Column 값 조회

Statement나 PreparedStatement의 executeQuery()를 통해서 얻은 ResultSet 객체를 통해 데이터를 조회할 수 있다.

...
ResultSet rs = pstmt.executeQuery();
while(rs.next())
{
    String id = rs.getString(1);
    String name = rs.getString(2);
    int age = rs.getInt(3);
    ...
}

테이블의 데이터를 조회한 후 ResultSet의 각종 getter method를 통해 해당 column의 내용을 얻을 수 있다. 테이블의 데이터는 GOLDILOCKS 데이터 타입의 원래 형태로 JDBC 드라이버에 전달되며, 사용자가 호출한 getter method 종류에 따라 적절한 Java 데이터 타입으로 변환되어 사용자에게 전달된다. GOLDILOCKS 데이터 타입과 getter method와의 타입 변환 매핑은 GOLDILOCKS 타입에 대한 getter method 지원 여부-1를 참조한다.

GOLDILOCKS 데이터 타입을 해당 getter의 타입으로 변환할 수 없으면 SQLException이 발생한다.

Closing ResultSet

사용을 마친 ResultSet의 자원은 close()를 통해 해제할 수 있다. 사용자가 명시적으로 close()를 호출하지 않아도 다음과 같은 경우에는 ResultSet의 close()를 호출한 것과 동일한 결과를 가져온다.

위의 세 번째 경우에 하나의 statement로부터 생성되는 ResultSet의 경우 동시에 두 개가 유지될 수 없다. 마지막 executeQuery()를 통해 생성된 ResultSet 객체만 유효하다.

Fetch Size

JDBC는 statement의 setFetchSize(int rows)를 통해 서버로부터 한 번에 fetch해오는 row 개수를 지정할 수 있다. GOLDILOCKS의 ResultSet은 이 속성의 기본값이 0이다. 0은 서버가 fetch 할 row의 개수를 자동으로 정하는데, forward only인 경우 한 통신 패킷에 담을 수 있는 최대 row 개수이고, scrollable인 경우 100개로 고정된다. 이 값이 크면 JDBC ResultSet이 차지하는 메모리 양이 많아지고, 너무 작으면 통신이 자주 발생한다.

이 값은 주로 scrollable ResultSet에 많이 사용하는데, 왜냐하면 scroll sensitive라 할지라도 ResultSet의 row 캐시 내에서 이동할 때는 sensitive하지 않기 때문에 이 값을 너무 크게 잡으면 row에 대한 최신 갱신 정보를 가질 수 없기 때문이다.

필드 크기 제한

JDBC는 statement의 setMaxFieldSize(int size)를 통해 한 column의 최대 길이를 제한할 수 있다. 이 설정에 의해 CHAR, VARCHAR, LONG VARCHAR, BINARY, VARBINARY, LONG VARBINARY 타입에 대해 최대 길이를 제한할 수 있다. 이 길이를 넘는 데이터는 잘라 버린다. 기본값은 0이며, 이 경우 최대 길이를 제한하지 않는다.

INTEGER, DATE와 같은 다른 타입에 대해서는 이 속성이 무시된다.

ResultSet 스크롤

Scrollable ResultSet 획득

Scrollable ResultSet은 scroll sensitive와 scroll insensitive 두 가지이다. Scroll sensitive는 ResultSet을 순회하는 동안 자기 트랜잭션에 의해서든, 타 트랜잭션에 의해서든 갱신된 값들을 볼 수 있는 커서 유형이고, scroll insensitive는 그렇지 못한 커서이다. GOLDILOCKS 서버는 두 가지 스크롤 유형을 모두 지원하며, JDBC를 통해서도 그 기능을 자유롭게 사용할 수 있다.

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                     ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("select id, name, age from emp");

라인 1처럼 statement를 생성할 때 ResultSet 타입을 TYPE_SCROLL_SENSITIVE로 설정하면 이 statement 객체로부터 생성되는 ResultSet은 모두 scroll sensitive 커서가 된다. 단, 현재 GOLDILOCKS는 updatable ResultSet은 지원하지 않는다.

Scroll insensitive인 ResultSet을 얻으려면 타입을 TYPE_SCROLL_INSENSITIVE로 설정해야 한다. 기본값은 TYPE_FORWARD_ONLY이다.

단, scroll sensitive ResultSet이라 하더라도 ResultSet의 row 캐시 내에서 이동할 때는 최신값을 볼 수 없고 갱신 유무도 알 수 없다. Row를 서버로부터 다시 fetch 해와야만 알 수 있다.

스크롤 하기

JDBC API는 커서를 스크롤 하기 위해 다음과 같은 method를 제공한다.

public boolean next() throws SQLException;
public boolean previous() throws SQLException;
public boolean first() throws SQLException;
public boolean last() throws SQLException;
public boolean absolute(int rows) throws SQLException;
public boolean relative(int rows) throws SQLException;
public void beforeFirst() throws SQLException;
public void afterLast() throws SQLException;

next()는 forward only나 scrollable ResultSet에 모두 사용할 수 있는 method이며, 커서 위치를 다음 row로 이동시킨다. 이동한 위치에서 row를 읽을 수 있으면 true를, 그렇지 않을 경우에는 false를 반환한다. 그 외의 method들은 scrollable ResultSet에만 사용할 수 있다.

previous()는 이전 row로, first()는 첫 번째 row로, last()는 마지막 row로, absolute()는 절대 위치로, relative()는 현재 위치로부터 상대 위치로 이동시킨다. beforeFirst()는 첫 번째 row 이전으로 위치시키며, afterLast()는 마지막 row의 다음에 위치시킨다.

rs.afterLast();
while (rs.previous())
{
    String id = rs.getString(1);
    String name = rs.getString(2);
    int age = rs.getInt(3);
    ...
}

위 코드는 마지막 row부터 첫 번째 row까지 거꾸로 조회한다.

현재 커서의 위치는 다음 method를 통해 알 수 있다.

public int getRow() throws SQLException;

스크롤 원리

ResultSet 스크롤은 사용하기 간단한 편이지만, 내부 동작 원리를 알지 못하면 성능이 크게 저하될 수도 있어 주의해서 사용해야 한다. 스크롤은 JDBC 드라이버의 ResultSet 내의 result cache에서 수행되지만, cache를 벗어난 범위에 대해서는 서버에서 스크롤이 수행되며 이에 따라 통신이 발생하면 성능이 저하될 수 있다.

Scrollable ResultSet의 fetch size는 내부 (internal) 기본값이 100이다. (외부 기본값은 0이며, 이 값은 setFetchSize() method를 통해 변경할 수 있다.) 즉, 한 번에 JDBC 드라이버로 가져오는 row 개수가 100개라는 뜻이다. ResultSet의 row 캐시는 100개의 row로 구성되는데, 이동시키려는 row 위치가 캐시 내에 있을 경우, ResultSet의 커서 위치만 바꾸면 된다. 하지만 캐시 내에 없을 경우에는 이동시키려는 위치의 row를 다시 서버로부터 가져와야 한다. 이 때 이동시키려는 row를 포함한 row set을 가져오는 방식을 알아야 한다.

예를 들어, ResultSet이 1번부터 100번의 row를 가지고 있고 현재 커서 위치가 100번에 있을 경우에 next()를 호출하게 되면 다음 row가 캐시 내에 없기 때문에 101번부터 200번까지의 row를 서버로부터 fetch해 와야 한다. 반면에 101번부터 200번까지의 row가 ResultSet 캐시 내에 있고, 현재 위치가 101번 row에 있을 때 previous()를 호출한 경우, 서버로부터 100번부터 199번 row를 fetch 해온다면 이는 적절하지 못하다. 만약 이렇게 구현한다면 previous()를 호출할 때마다 서버에서 매번 fetch 해와야 하기 때문이다. GOLDILOCKS는 이런 비효율을 방지하기 위해 previous()를 호출하여 해당 row를 서버로부터 가져와야 하는 상황이 되면 해당 row를 마지막으로 하는 row set을 서버로부터 가져온다. 즉, previous()에 의해 100번 row를 fetch 해와야 하는 상황이라면 1번부터 100번까지의 row를 fetch 해온다. 그러면 previous()에 유리하도록 fetch하게 된다.

이 규칙을 일반화하면 다음과 같다.

즉, 뒤로 이동할 때는 next()에 유리하도록, 앞으로 이동할 때는 previous()에 유리하도록 fetch한다. 이는 absolute(), relative()로 이동할 때도 마찬가지이다.

추가 타입 사용

Interval 타입

GOLDILOCKS는 interval과 관련하여 다음과 같은 13가지 타입을 지원한다.

JDBC를 이용하여 sunje.goldilocks.jdbc.GoldilocksInterval 객체를 생성하면 PreparedStatement의 setObject()를 통해 interval 데이터를 테이블에 추가할 수 있다.

GoldilocksInterval 객체는 GoldilocksInterval의 static method인 createIntervalXXX를 사용하여 생성할 수 있다.

import sunje.goldilocks.jdbc.GoldilocksInterval;

...
GoldilocksInterval interval = GoldilocksInterval.createIntervalDayToSecond(2, 6, "2 08:23:54.560843");
PreparedStatement pstmt = con.prepareStatement("insert into interval_table values (?,?)");
pstmt.setString(1, someId);
pstmt.setObject(2, interval);
pstmt.executeUpdate();

createIntervalXXX method에 대한 자세한 내용은 GoldilocksInterval을 참조한다. 이와 같이 GoldilocksInterval을 생성하여 setObject를 통해 바인딩 할 수 있다. 또는 타입을 명시하기 위해 다음과 같이 실행해도 된다.

import sunje.goldilocks.jdbc.GoldilocksTypes;
...
pstmt.setObject(2, interval, GoldilocksTypes.INTERVAL_DAY_TO_SECOND);

GoldilocksInterval 객체없이 string 문자열로 데이터를 추가할 수 있다.

pstmt.setObject(2, "2 08:23:54.560843", GoldilocksTypes.INTERVAL_DAY_TO_SECOND);

이 경우 JDBC 드라이버 내에서 GoldilocksInterval 객체를 생성하여 호스트 변수에 바인딩한다. 또는 setString() method를 통해 문자열로 바인딩 할 수도 있다.

pstmt.setString(2, "2 08:23:54.560843");

이렇게 하면 서버에 문자열 그대로 전송되며 서버에서 문자열을 interval day to second 타입으로 변환하여 추가한다.

데이터베이스로부터 interval 타입을 조회하려면 ResultSet의 getObject()나 getString()을 이용한다.

import sunje.goldilocks.jdbc.GoldilocksInterval;

ResultSet rs = stmt.executeQuery("select interval_value from some_table");
while (rs.next())
{
    GoldilocksInterval interval = (GoldilocksInterval)rs.getObject(1);
    System.out.println("type = " + interval.getTypeName() + 
                       ", value = " + interval.toString());
}

ResultSet의 getObject()를 통해 GoldilocksInterval 타입의 데이터를 얻을 수 있다. GoldilocksInterval 클래스는 각종 시간 데이터를 얻을 수 있는 getYear(), getHour() 등의 getter를 제공한다. getter API에 대한 자세한 내용은 GoldilocksInterval을 참조한다.

Time with time zone과 Timestamp with time zone 타입

GOLDILOCKS는 시간과 관련하여 date, time, timestamp와 같은 SQL 표준 타입 뿐만 아니라 time with time zone과 timestamp with time zone 타입도 제공한다.

CREATE TABLE SAMPLE_TABLE ( C1 TIME WITH TIME ZONE,
                            C2 TIMESTAMP WITH TIME ZONE );

GOLDILOCKS JDBC는 time with time zone과 timestamp with time zone 타입의 데이터를 추가하기 위해 GoldilocksPreparedStatement 클래스에 setTimeTimeZone (int colIndex, time time, calendar timezone) method와 setTimestampTimeZone (int colIndex, timestamp time, calendar timezone) method를 제공한다. 자세한 내용은 setTimeTimeZonesetTimestampTimeZone을 참조한다.

물론 기존의 setTime()과 setTimestamp() method로도 추가할 수 있지만, 이 column의 time zone 값은 무조건 Java 실행 환경의 local time zone으로 설정된다. 따라서 다양한 time zone 정보를 추가하기 위해서는 setTimeTimeZone()이나 setTimestampTimeZone을 사용해야 한다.

setTimeTimeZone과 setTimestampTimeZone으로 주어진 time, timestamp 데이터를 주어진 time zone 값과 함께 추가할 수 있다.

import sunje.goldilocks.jdbc.GoldilocksPreparedStatement;

PreparedStatement pstmt = con.prepareStatement(
    "INSERT INTO SAMPLE_TABLE VALUES (?,?,?,?)");
Calendar now = Calendar.getInstance();
Calendar usNow = Calendar.getInstance(TimeZone.getTimeZone("GMT-8"));

Time t = new Time(now.getTimeInMillis());
Timestamp ts = new Timestamp(now.getTimeInMillis());

pstmt.setTime(1, t);
pstmt.setTimestamp(2, ts);
pstmt.executeUpdate();

((GoldilocksPreparedStatement)pstmt).setTimeTimeZone(1, t, now);
((GoldilocksPreparedStatement)pstmt).setTimestampTimeZone(2, ts, now);
pstmt.executeUpdate();

((GoldilocksPreparedStatement)pstmt).setTimeTimeZone(1, t, usNow);
((GoldilocksPreparedStatement)pstmt).setTimestampTimeZone(2, ts, usNow);
pstmt.executeUpdate();

11, 12 라인은 해당 column에 time 타입과 timestamp 타입으로 바인딩한다. t와 ts 값이 각각 서버로 전달되어 서버에서 기본 time zone 값이 DB column에 추가된다.

이에 반해 15, 16 라인은 해당 column에 time with time zone 타입과 timestamp with time zone 타입으로 바인딩하여, time zone 정보도 함께 서버로 전달한다. 결과적으로 서버와 client의 time zone 설정이 동일할 경우, 11 ~ 13 라인에 의해 추가되는 row와 15 ~ 17 라인에 의해 추가되는 row는 동일하다.

19, 20 라인은 GMT-8 시간대의 time zone 정보를 추가한다.

Time with time zone과 timestamp with time zone의 데이터를 조회하는 방법은 크게 두 가지이다. 서버로부터 char로 얻는 방법과 JDBC로 해당 타입의 데이터를 가져와서 time이나 timestamp 객체로 얻는 방법이 있다.

ResultSet rs = stmt.executeQuery("select c1, cast(c1 as char(33)), c2, cast(c2 as char(33)) from sample_table");
while (rs.next())
{
    System.out.println("c1 = " + rs.getTime(1).toString());
    System.out.println("c1 as char = " + rs.getString(2));

    System.out.println("c2 = " + rs.getTimestamp(3).toString());
    System.out.println("c2 as char = " + rs.getString(4));
}

위 코드를 실행하면 다음과 같은 결과를 확인할 수 있다.

c1 = 12:35:26
c1 as char = 12:35:26.052000 +09:00           
c2 = 2014-03-27 12:35:26.052
c2 as char = 2014-03-27 12:35:26.052000 +09:00
c1 = 12:35:26
c1 as char = 12:35:26.052000 +09:00           
c2 = 2014-03-27 12:35:26.052
c2 as char = 2014-03-27 12:35:26.052000 +09:00
c1 = 12:35:26
c1 as char = 19:35:26.052000 -08:00           
c2 = 2014-03-27 12:35:26.052
c2 as char = 2014-03-26 19:35:26.052000 -08:00

로깅

로깅 종류

JDBC를 이용하는 프로젝트를 개발할 때, JDBC 드라이버가 각종 로그를 남길 수 있으면 여러가지로 도움이 된다. GOLDILOCKS는 프로젝트를 개발할 때만이 아니라 운용할 때도 유용한 정보를 로깅할 수 있는 기능을 제공한다.
로깅의 종류는 세 가지인데 trace log, protocol log, query log 이다.

Trace log는 JDBC API가 호출될 때마다 정보를 남긴다. 어떤 JDBC API가 호출되는 지를 알 수 있다. Protocol log는 JDBC 드라이버와 GOLDILOCKS 서버 사이에 통신 패킷을 주고 받는 상황을 보여준다. Query log는 PreparedStatement나 statement가 실행될 때, 실행할 SQL 문을 기록한다.

DriverManager를 이용한 로깅

먼저 DriverManager를 이용하여 로깅을 남길 수 있다. DriverManager에 setLogWriter() method를 이용하여 로깅할 매체를 결정할 수 있고, connection url에 남길 로깅의 종류를 명시한다.

DriverManager.setLogWriter(new PrintWriter(System.out));
String url = "jdbc:goldilocks://localhost:22581/test?trace_log=on&query_log=on";
Connection con = DriverManager.getConnection(url, "TEST", "test");

1번 라인은 로깅 매체를 정의하는 것이다. 모든 로깅을 콘솔로 출력하게 한다. 2번 라인은 connection URL을 정의하는 것인데, ? 문자 뒤에 프로퍼티를 정의할 수 있다. trace_log, query_log를 사용하겠다는 의미이다.

이와 같이 이 프로퍼티들은 URL에 명시할 수도 있고, properties 객체로 정의할 수도 있다.

Properties prop = new Properties();
prop.put("trace_log", "on");
prop.put("query_log", "on");
prop.put("protocol_log", "on");
prop.put("user", "TEST");
prop.put("password", test");
Connection con = DriverManager.getConnection(url, prop);

GOLDILOCKS에서 사용할 수 있는 connection property들은 The internal link is invalid.에 정의되어 있다.

간혹 DriverManager의 setLogWriter()를 호출하기 어려운 경우가 있다. 예를 들어, 미들웨어를 사용하는 경우 저런 코드를 추가할 수 없다. 그런 경우에 대비해 GOLDILOCKS JDBC는 global_logger라는 전역 프로퍼티를 제공한다. 다른 일반적인 프로퍼티들은 하나의 connection에만 적용되지만, 이 속성은 전역적으로 적용된다. 즉, 이 프로퍼티를 설정하면 DriverManager.setLogWriter()를 호출하지 않아도 된다.

String url = "jdbc:goldilocks://localhost:22581/test?" +            
             "global_logger=console&trace_log=on&query_log=on";
Connection con = DriverManager.getConnection(url, "TEST", "test");

global_logger 속성은 처음 한 번만 적용되는데 만약 DriverManager에 이미 log writer가 설정되어 있으면 이 속성은 무시된다. 이 속성의 값으로는 현재 console만 지원된다. 다른 값인 경우에는 아무런 동작을 하지 않는다.

DataSource를 이용한 로깅

DriverManager와는 다르게 DataSource는 객체별로 log writer를 설정할 수 있다. 하나의 DataSource 객체에 log writer를 세팅하면 그 DataSource로부터 생성되는 모든 connection은 그 log writer로 로깅된다. DataSource에 로깅을 설정하는 방법은 다음과 같다.

import sunje.goldilocks.jdbc.GoldilocksDataSource;
...
GoldilocksDataSource ds = new sunje.goldilocks.jdbc.GoldilocksDataSource();
ds.setServerName("localhost");
ds.setDatabaseName("test");
ds.setUser("TEST");
ds.setPassword("test");
ds.setPortNumber(22581);
ds.setLogTarget("console");
ds.setTraceLog("on");
ds.setQueryLog("on");
ds.setProtocolLog("on");
Connection con = ds.getConnection();

이와 같이 setLogTarget(), setTraceLog(), setQueryLog(), setProtocolLog() method를 사용하여 로깅 기능을 설정할 수 있다. setLogTarget() 대신 DataSource의 setLogWriter()를 호출해도 된다. 다만 미들웨어를 사용하는 경우에는 setLogWriter()와 같은 method를 직접 호출할 수 없기 때문에 property로 제어해야 하는데, 이 때 logTarget, traceLog, queryLog, protocolLog 속성을 정의하면 미들웨어가 자동으로 이 method들을 호출한다.

Plan Text 조회

사용법

GOLDILOCKS ODBC를 사용하면 실행된 statement의 plan text를 얻어올 수 있는 것처럼 GOLDILOCKS JDBC를 사용해서도 plan text를 얻어올 수 있다. GoldilocksStatement 클래스에 비 표준 API method를 사용하여 plan text를 생성하도록 설정할 수 있고, 만들어진 plan text를 얻어올 수도 있다.

Connection con = ...
GoldilocksStatement stmt = (GoldilocksStatement)con.createStatement();
stmt.setExplainPlanOption(GoldilocksStatement.EXPLAIN_PLAN_OPTION_ON);
ResultSet rs = stmt.executeQuery("select * from t1");
System.out.println(stmt.getExplainPlan());

예를 들어 간단한 테이블을 조회했을 때의 plan text는 다음과 같이 출력된다.

< Execution Plan >
==========================================================================
|  IDX  |  NODE DESCRIPTION                                |       ROWS |
--------------------------------------------------------------------------
|    0  |  SELECT STATEMENT                                |            |
|    1  |    TABLE ACCESS ("T1")                           |          0 |
==========================================================================
     1  -  READ COLUMNS : A

옵션 종류

GOLDILOCKS는 다음과 같이 plan text 생성과 관련된 네가지 속성을 제공한다.

이 속성들은 GoldilocksStatement.setExplainPlanOption(int) method를 사용하여 설정할 수 있으며 한 번 설정하면 계속해서 이 속성이 유지된다. 속성의 상수값은 GoldilocksStatement에 정의되어 있다.

SELECT 구문이 아닌 DML이나 기타 SQL 구문은 실행할 때 plan text가 생성되지만 SELECT 구문은 fetch되고 서버 내에서 커서가 끝까지 갔을 때 plan text가 생성된다. 따라서 SELECT 구문일 경우 ResultSet으로 모든 row를 순회한 다음에 plan text를 얻어야 한다. 단, 테이블에 row가 적을 경우에는 끝까지 fetch하지 않아도 서버 커서의 끝까지 순회할 수 있으므로 이 경우 plan text를 얻을 수 있다.

Connection Failover

GOLDILOCKS는 client 레벨 (JDBC, ODBC)의 connection failover를 지원한다. GOLDILOCKS에 JDBC 또는 ODBC를 이용하여 client/ server 모드로 접속한 응용 프로그램은 연결에 실패하거나 연결이 끊길 경우, 자동으로 대체 서버로 연결할 수 있다. 이를 통해 여러 대의 서버를 활용한 고가용성 응용 프로그램을 작성할 수 있도록 해준다. 특히 웹 서버와 연동된 환경에서 연결 속성 (connection property)을 통해 주 서버 URL과 대체 서버 URL을 등록하면 connection pool로부터 가져온 connection 객체를 끊길 걱정없이 안정적으로 사용할 수 있다. Failover는 전적으로 드라이버 내부에서 자동 진행되며 사용자는 재접속에 대한 로직을 고민할 필요없다.

Failover 기능을 사용하려면 alternate_servers 속성을 부여해야 한다. 이 속성값으로 대체 서버의 IP와 port를 부여할 수 있다. 콤마 (,)를 사용하여 여러 개의 대체 서버를 명시할 수도 있다.

Class.forName("sunje.goldilocks.jdbc.GoldilocksDriver");

String url = "jdbc:goldilocks://192.168.0.101:22581/test";
Property prop = new Properties();
prop.setProperty("user", "TEST");
prop.setProperty("password", "test");
prop.setProperty("alternate_servers", "192.168.0.201:22581");
Connection con = DriverManager.getConnection(url, prop); 1
Statement stmt = con.createStatement();
stmt.executeUpdate("insert into time_tab values (sysdate)"); 2
...

예를 들어, 1에서 주 서버 (192.168.0.101)의 연결이 실패하면 자동으로 대체 서버 (192.168.0.201)로 접속한 후 connection 객체를 반환한다. 사용자에게는 별다른 에러가 반환되지 않는다. 만약 2에서 executeUpdate() 하는 도중에 연결이 끊기거나 그 전에 끊어져서 서버와 통신을 할 수 없을 경우 드라이버 내부에서 자동으로 대체 서버로 접속하여 기존 connection 객체를 계속해서 사용할 수 있도록 조치한 후 SQLException이 발생한다. 사용자는 SQLException을 처리한 후에 기존 connection 객체를 계속해서 사용할 수 있다.

Connection 객체의 getWarnings()를 통해 failover 여부를 알 수 있다.

GOLDILOCKS JDBC의 failover 특징 중에 하나는 connection 객체로부터 생성된 statement 객체나 PreparedStatement 객체를 계속해서 사용할 수 있다는 점이다. (ResultSet은 계속해서 사용할 수 없다)

특히 PreparedStatement 들은 failover가 발생하면 내부적으로 대체 서버에서 다시 prepare 작업을 수행하므로 사용자가 계속해서 이 객체를 사용할 수 있다.

Connection con = DriverManager.getConnection(url, prop);
PreparedStatement pstmt = 
    con.prepareStatement("insert into t1 values (?,?)");
...
try
{
    pstmt.setInt(1, 100);
    pstmt.setString(2, "John");
    pstmt.executeUpdate();
}
catch (SQLException sException)
{
    if (sException.getErrorCode() == 21012)
    {
pstmt.executeUpdate(); 
    }
    else
    {
        ...
    }
}

GOLDILOCKS JDBC 드라이버는 failover와 관련해 몇 가지 속성을 제공한다. 이를 통해 failover 유형, 접속 순서 및 failover시 사용되는 간단한 정책 등을 결정할 수 있다.

failover_type

이 속성으로 failover 유형을 선택할 수 있다. 위 예제 코드 1에서 발생하는 failover를 connection failover라 하고 2에서 발생하는 failover를 session failover라 부른다. 이 속성값으로 connection을 부여하면 connection failover만 수행하게 하며, session을 부여하면 connection failover와 session failover를 모두 수행하게 한다. 기본값은 connection이다.

failover_granularity

Failover가 발생하면 현재의 connection 객체로부터 생성된 PreparedStatement 객체들에 대체 서버로 접속한 후 prepare 작업을 다시 수행하는데 이 때 대체 서버에서 prepare가 실패했을 경우 (서버 환경이 달라서 에러가 발생할 수 있음) failover 자체를 실패로 처리할지 또는 prepare 에러를 무시할지 여부를 이 속성이 결정한다. 현재 이 속성값으로 0과 1을 부여할 수 있는데, 0을 부여하면 prepare 에러를 무시한 채 failover를 계속해서 수행할 수 있게하고, 1을 주면 failover가 실패하도록 한다. 기본값은 0이다. 만약 0을 부여하고 prepare에 실패하면 PreparedStatement 객체를 계속해서 사용할 수 없고 사용자가 다시 직접 PreparedStatement 객체를 생성해야 한다.

Direct Attach 모드 접속

GOLDILOCKS JDBC 1.1부터 기존 TCP/ IP 기반의 Client/ Server 모드 (C/S 모드) 외에 Direct Attach 모드 (D/A 모드) 연결을 제공한다. 이 연결 방식은 ODBC D/A 모드 접속과 마찬가지로 서버 프로세스와 직접 연동하여 하나의 프로세스 안에 (jvm과 같은 프로세스 안에) 서버 모듈이 연동되어 작동한다. 그렇기 때문에 원격 호스트에서는 D/A 모드로 접속할 수 없다.

D/A 모드는 in-memory 데이터베이스인 GOLDILOCKS의 빠른 처리라는 장점을 살리기 위해 고안된 특별한 연결 방식이다. TCP/ IP 기반의 접속으로는 GOLDILOCKS의 빠른 트랜잭션 처리 효과가 값비싼 네트워크 비용으로 상쇄되기 때문에 빠른 처리를 요구하는 상황에서는 다른 대안이 필요하다. 비록 GOLDILOCKS 서버와 같은 호스트 내에서 실행해야 한다는 제약이 있지만 빠른 처리를 필요로 하는 경우 D/A 모드 접속은 좋은 대안이 될 수 있다.

D/A 모드로 접속한 JDBC 프로그램은 jvm 내에서 DB connection이 처음 생성되면 GOLDILOCKS jni 라이브러리가 로딩되어 서버의 기능을 직접 호출할 수 있다. 네트워크 비용없이 jvm에서 native interface를 통해 서버 모듈을 직접 호출할 수 있기 때문에 기존의 CS 모드보다 빠른 처리가 가능하다.

접속 방법

D/A 모드로 접속하기 위해 connection URL에 기존 ip:port 대신 0.0.0.0:0을 사용한다. 기존의 URL 방식을 그대로 사용할 수 있으며 0.0.0.0:0이라는 특별한 ip:port 주소를 사용하여 기존 응용 프로그램의 수정을 최소화할 수 있다. 또는 da라는 특수 프로토콜을 URL에 사용하면 D/A 모드로 접속할 수 있다.

Connection con =
 DriverManager.getConnection("jdbc:goldilocks://0.0.0.0:0/test","TEST","test");

또는

Connection con =
 DriverManager.getConnection("jdbc:goldilocks:da/test", "TEST", "test");

D/A 접속의 특징

D/A 모드로 접속하면 jvm 안에서 GOLDILOCKS server 모듈을 직접 호출할 수 있다. JDBC 프로그램과 GOLDILOCKS server 모듈 사이에는 Java Native Interface (JNI)를 통해 호출한다. JNI 호출 비용이 비싼 것을 고려하여 최소 호출 비용으로 서버 모듈을 사용하기 때문에 기존 TCP/ IP 기반의 JDBC보다 두 배 이상성능이 빨라진다.

기존 TCP/ IP 기반의 접속을 사용할 때는 goldilocks6.jar 파일만 사용하지만 D/A 모드로 접속할 때는 $GOLDILOCKS_HOME/lib에 있는 libgoldilocksjni.so와 libgoldilocksas.so 파일을 동적으로 로딩해서 사용한다. 따라서 두 라이브러리 파일이 없으면 연결할 때 에러가 발생한다. 하지만 Java 프로그램을 구동할 때 라이브러리 파일의 위치를 별도로 명시할 필요는 없다. goldilocks6.jar 파일과 같은 디렉토리에 있는 한 현재 디렉토리부터 이 두 개의 라이브러리 파일을 찾아서 로딩하기 때문이다.

Global Connection

클러스터 환경에서 응용 프로그램이 질의 처리에 적합한 노드를 선택해서 수행할 수 있는 global connection 기능을 지원한다.

설정

Global connection을 사용하려면 locality_aware_transaction 속성값과 함께 locator_file이나 locator_host, locator_port를 설정해야 한다. Global session 기능을 사용하려면 use_global_session 속성값을 1로 설정해야 한다.

Properties prop = new Properties();
prop.put("locality_aware_transaction", "1");
prop.put("locator_file", "/home/goldilocks/.location.ini");
prop.put("user", "TEST");
prop.put("password", test");
Connection con = DriverManager.getConnection(url, prop);
String url = "jdbc:goldilocks://192.168.0.1:22581/test?" +            
             "locality_aware_transaction=1&locator_host=192.168.0.2&locator_port=42581";
Connection con = DriverManager.getConnection(url, "TEST", "test");

처리 과정

  1. 데이터베이스 접속

사용자로부터 입력 받은 서버로 연결하여 클러스터 시스템의 정보를 획득한 후에 locator file이나 glocator를 통해 클러스터 시스템 정보를 구축하며, 클러스터 시스템의 모든 노드에 접속한다.

  1. Statement 실행

클러스터 시스템 정보가 구축되어 있지 않으면 locator file이나 glocator를 통해 클러스터 시스템 정보를 구축하며, 클러스터 시스템의 모든 노드에 접속한다.

클러스터에 노드를 추가하여 새로운 노드에 접속한 경우, 다른 노드의 모든 statement들을 해당 노드에 동일하게 생성한 후에 SQL을 실행할 준비까지 한다.

Statement class의 경우, sharding key 정보가 없으므로 locality_group_policy나 locality_member_policy 속성에 따라 노드를 선택하여 statement를 실행한다.

PreparedStatement나 CallableStatement class의 경우, sharding key 정보가 구축되어 있지 않으면 임의의 서버로부터 해당 SQL의 sharding key 정보를 구축한다. Sharding key 정보가 구축되어 있으면 sharding key 정보나 locality_group_policy, locality_member_policy를 이용하여 적합한 노드를 선택해 질의를 수행한다.

선택된 노드에 장애가 발생하면 해당 노드를 제외하고 적합한 노드를 다시 선택하여 질의를 수행한다.

Statement를 실행한 후에 sharding 정보가 변경되면 구축된 sharding key 정보를 삭제한다.

Statement를 실행한 후에 클러스터 노드가 추가/ 삭제되는 등 클러스터 시스템 정보가 변경되면 구축된 클러스터 시스템 정보를 삭제한다.

  1. ResultSet 데이터 수신

SQL이 수행된 노드로부터 데이터를 가지고 온다.

  1. ResultSet 닫기

SQL이 수행된 노드에서 커서를 닫는다.

  1. Statement 닫기

연결된 모든 노드에서 statement를 해제한다.

  1. 데이터베이스 닫기

모든 노드와의 접속을 해제한다.

고가용성을 위한 예외 처리

Global connection을 사용할 때 운영 중 선택된 노드에 장애가 발생하면 트랜잭션 발생 및 SELECT 진행 여부에 따라 다음과 같이 동작한다.

트랜잭션이 아직 없는 경우 선택된 노드에 장애가 발생하면 JDBC 내부에서 다른 노드를 선택하여 해당 질의를 수행한다. 선택된 노드에 장애가 발생했지만 다른 노드에서 정상적으로 수행했으므로 사용자에게 에러를 전달하지 않는다.

트랜잭션이 발생하였거나 ResultSet.next()가 진행 중일 때 선택된 노드에 장애가 발생하면 JDBC는 현재 작업을 더 이상 진행할 수 없어 21047(Retry the transactional operations again) 에러를 전달한다. 21047 에러가 발생하면 사용자는 해당 트랜잭션을 다시 수행하거나 SELECT를 다시 수행해야 한다.

PreparedStatement pstmt = con.prepareStatement("INSERT INTO T1 VALUES (?)");

boolean retry;

do
{
    retry = false;

    try
    {
        pstmt.setInt(1, 1);
        pstmt.executeUpdate();
    }
    catch (SQLException e)
    {
        if (e.getErrorCode() == 21047)
        {
            retry = true;
        }
        else
        {
            throw e;
        }       
    }
} while (retry == true);
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM T1 WHERE C1 = ?");

boolean retry;

do
{
    retry = false;

    try
    {
        pstmt.setInt(1, 1);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next())
        {
            ...
        }
        rs.close();
    }
    catch (SQLException e)
    {
        if (e.getErrorCode() == 21047)
        {
            retry = true;
        }
        else
        {
            throw e;
        }       
    }
} while (retry == true);

트랜잭션을 COMMIT 할 때 선택된 노드에 장애가 발생하면 JDBC는 선택된 노드에 장애가 발생 전에 트랜잭션이 COMMIT 되었는지 여부를 다른 노드를 통해 확인한다. 만약 선택된 노드에 장애가 발생하였지만 트랜잭션이 정상적으로 COMMIT 되었을 경우에는 에러를 전달하지 않는다. 또한 트랜잭션이 COMMIT 되지 않은 상태에서 선택된 노드에 장애가 발생하면 21047(Retry the transactional operations again) 에러를 전달한다. 21047 에러가 발생하면 사용자는 해당 트랜잭션을 다시 수행해야 한다.

트랜잭션을 ROLLBACK 할 때 선택된 노드에 장애가 발생하면 JDBC가 에러를 전달하지 않는다. 노드 장애로 인해 해당 트랜잭션이 이미 ROLLBACK 되었기 때문이다.

con.setAutoCommit(false);

PreparedStatement pstmt = con.prepareStatement("INSERT INTO T1 VALUES (?)");

boolean retry;

do
{
    retry = false;

    try
    {
        pstmt.setInt(1, 1);
        pstmt.executeUpdate();
        con.commit();
    }
    catch (SQLException e)
    {
        if (e.getErrorCode() == 21047)
        {
            retry = true;
        }
        else
        {
            throw e;
        }       
    }
} while (retry == true);

제약 사항

Statement class에는 질의에 적합한 노드를 찾기 위한 정보가 없기 때문에 locality_group_policy와 locality_member_policy 속성에 따라 노드를 선택한다.

GLOBAL CONNECTION을 사용할 때 SQL 구문으로 COMMIT이나 ROLLBACK을 수행하면 트랜잭션 상태 변화를 감지할 수 없다. 트랜잭션을 COMMIT 하거나 ROLLBACK 하려면 반드시 Connection.commit(). Connection.rollback()을 사용해야 한다.

Statement Pooling

GOLDILOCKS는 statement pooling 기능을 지원한다. Statement pooling은 반복문이나 반복적으로 호출되는 메소드와 같이 반복적으로 사용되는 statement를 pooling 하여 성능을 향상시키는 기능이다. JDBC 3.0에서 statement pooling 인터페이스를 정의한다.

응용 프로그램은 statement pool을 사용하여 특정 connection과 관련된 statement를 pooling 한다. 각 connection 객체는 자신의 pool을 갖는다. GoldilocksConnection에는 statement pool을 활성화하는 메소드가 포함되어 있다. Statement pool을 사용하면 statement 객체는 close 메소드가 호출될 때 pooling 된다.

설명

Statement pool을 활성화하고 statement 객체의 close 메소드를 호출하면 GOLDILOCKS JDBC 드라이버는 자동으로 statement, PreparedStatement, CallableStatement를 pooling 한다. PreparedStatement, CallableStatement 객체는 SQL 문자열을 키 값으로 사용하여 pooling 한다. JDBC 드라이버는 PreparedStatement나 CallableStatement를 생성할 때 pool에서 이들을 자동으로 비교/ 검색한다.

비교 기준은 다음과 같다.

Statement 객체의 SQL 문자열이 변경될 수 있기 때문에 pooling을 위해 SQL 문자열이 사용되지 않고 JDBC 드라이버에서 자동으로 처리한다.

Pool에서 검색하는 도중에 일치하는 statement를 발견하면 이를 반환하고 발견하지 못하면 새 statement가 생성된다. 두 경우 모두 객체의 close 메소드를 호출하면 statement와 커서 및 상태가 pooling 된다. 다만 statement는 closed 상태가 된다. Closed 상태의 statement를 다시 사용하려면 SQL 문자열과 statement 타입, result set 속성이 모두 동일한 statement를 생성해야 한다.

Pooling 된 PreparedStatement와 CallableStatement 객체가 검색되면 상태와 데이터 정보는 자동으로 다시 초기화된 후 기본값으로 재설정된다. Statement pool이 가득차면 LRU 알고리즘으로 pool에서 제거된다. Statement pool에 저장된 statement들은 connection 객체의 close 메소드를 호출해야 정리할 수 있다.

사용

Statement Pool 활성화

Connection 객체의 statement pool을 사용하려면 STATEMENT_POOL_ON과 STATEMENT_POOL_SIZE 프로퍼티를 설정해야 한다. STATEMENT_POOL_ON 프로퍼티를 활성화하더라도 STATEMENT_POOL_SIZE의 기본값이 0이기 때문에 반드시 0 보다 큰 숫자를 사용해야 한다.

Properties 객체에 STATEMENT_POOL_ON과 STATEMENT_POOL_SIZE 프로퍼티를 추가하여 statement pool 기능을 활성화 할 수 있다. 그리고 이외에 GoldilocksDataSource API와 GoldilocksConnection API를 통해서도 statement pool을 활성화 할 수 있다.

GoldilocksDataSource를 통한 활성화

GoldilocksDataSource 클래스를 이용하면 모든 connection 객체는 동일한 STATEMENT_POOL_SIZE를 갖는 statement pool을 갖게 된다.

GoldilocksDataSource sDataSource = new GoldilocksDataSource();

sDataSource.setStatementPoolOn( true );
sDataSource.setStatementPoolSize( 10 );

다음과 같이 프로퍼티 설정값을 확인할 수 있다.

System.out.println("Statement Pool on:" + sDataSource.getStatementPoolOn());
System.out.println("Statement Pool size:" + sDataSource.getStatementPoolSize());
GoldilocksConnection을 통한 활성화

GoldilocksConnection 클래스를 이용하면 다른 객체와는 별개로 statement pool을 활성화할 수 있다.

GoldilocksConnection sCon = sDataSource.getConnection();

sCon.setStatementPoolOn( true );
sCon.setStatementPoolSize( 10 );

다음과 같이 프로퍼티 설정값을 확인할 수 있다.

System.out.println("Statement Pool on:" + sCon.getStatementPoolOn());
System.out.println("Statement Pool size:" + sCon.getStatementPoolSize());

Statement Pool 비활성화

활성화된 statement pool를 비활성화할 수 있다. 활성화 된 상태에서 비활성화 상태로 변경하면 statement pool에 저장된 statement들이 제거되면서 close 된다.

setStatementPoolOn 메소드를 이용한 비활성화

sCon.setStatementPoolOn(false);

setStatementPoolSize 메소드를 이용한 비활성화

sCon.setStatementPoolSize(0);

Statement 생성

Statement pool이 활성화된 상태에서 statement, PreparedStatement, CallableStatement를 생성하는 방식은 일반적인 생성 방식과 동일하다.

다음은 새 statement 객체를 생성하는 코드이다.

PreparedStatement sPstmt = sCon.prepareStatement( "INSERT INTO EMP VALUES ( ?, ? )" );

특정 Statement 비활성화

Statement pool을 활성화하면 GOLDILOCKS JDBC 드라이버가 자동으로 모든 statement를 pooling 한다. setPoolable 메소드를 사용하면 특정 statement를 pooling에서 제외할 수 있다.

다음은 isPoolable 메소드와 setPoolable 메소드로 pooling 여부를 확인하는 예이다.

PreparedStatement sPstmt = sCon.prepareStatement( "SELECT 1 FROM DUAL" );
System.out.println( "Is poolable: " + sPstmt.isPoolable() );
sPstmt.setPoolable( false );
System.out.println( "Is poolable: " + sPstmt.isPoolable() );

JDBC API References

Array

클래스가 구현되지 않았다.

free

void free() throws SQLException

getArray

Object getArray() throws SQLException
Object getArray(Map<String,Class<?>> map) throws SQLException
Object getArray(long index, int count) throws SQLException
Object getArray(long index, int count, Map<String,Class<?>> map) throws SQLException

getBaseType

int getBaseType() throws SQLException

getBaseTypeName

String getBaseTypeName() throws SQLException

getResultSet

ResultSet getResultSet() throws SQLException
ResultSet getResultSet(Map<String,Class<?>> map) throws SQLException
ResultSet getResultSet(long index, int count) throws SQLException
ResultSet getResultSet(long index, int count, Map<String,Class<?>> map) throws SQLException

Blob

free

void free() throws SQLException

getBinaryStream

InputStream getBinaryStream() throws SQLException
InputStream getBinaryStream(long pos, long length) throws SQLException

getBytes

byte[] getBytes(long pos, int length) throws SQLException

length

long length() throws SQLException

position

long position(byte[] pattern, long start) throws SQLException
long position(Blob pattern, long start) throws SQLException

setBinaryStream

OutputStream setBinaryStream(long pos) throws SQLException

setBytes

int setBytes(long pos, byte[] bytes) throws SQLException
int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException

truncate

void truncate(long len) throws SQLException

CallableStatement

getArray

Array getArray(int parameterIndex) throws SQLException
Array getArray(String parameterName) throws SQLException

getBigDecimal

BigDecimal getBigDecimal(int parameterIndex) throws SQLException
BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException
BigDecimal getBigDecimal(String parameterName) throws SQLException

getBlob

Blob getBlob(int parameterIndex) throws SQLException
Blob getBlob(String parameterName) throws SQLException

getBoolean

boolean getBoolean(int parameterIndex) throws SQLException
boolean getBoolean(String parameterName) throws SQLException

getByte

byte getByte(int parameterIndex) throws SQLException
byte getByte(String parameterName) throws SQLException

getBytes

byte[] getBytes(int parameterIndex) throws SQLException
byte[] getBytes(String parameterName) throws SQLException

getCharacterStream

Reader getCharacterStream(int parameterIndex) throws SQLException
Reader getCharacterStream(String parameterName) throws SQLException

getClob

Clob getClob(int parameterIndex) throws SQLException
Clob getClob(String parameterName) throws SQLException

getDate

Date getDate(int parameterIndex) throws SQLException
Date getDate(int parameterIndex, Calendar cal) throws SQLException
Date getDate(String parameterName) throws SQLException
Date getDate(String parameterName, Calendar cal) throws SQLException

getDouble

double getDouble(int parameterIndex) throws SQLException
double getDouble(String parameterName) throws SQLException

getFloat

float getFloat(int parameterIndex) throws SQLException
float getFloat(String parameterName) throws SQLException

getInt

int getInt(int parameterIndex) throws SQLException
int getInt(String parameterName) throws SQLException

getLong

long getLong(int parameterIndex) throws SQLException
long getLong(String parameterName) throws SQLException

getNCharacterStream

Reader getNCharacterStream(int parameterIndex) throws SQLException
Reader getNCharacterStream(String parameterName) throws SQLException

getNClob

NClob getNClob(int parameterIndex) throws SQLException
NClob getNClob(String parameterName) throws SQLException

getNString

String getNString(int parameterIndex) throws SQLException
String getNString(String parameterName) throws SQLException

getObject

Object getObject(int parameterIndex) throws SQLException
Object getObject(int parameterIndex, Map<String,Class<?>> map) throws SQLException
Object getObject(String parameterName) throws SQLException
Object getObject(String parameterName, Map<String,Class<?>> map) throws SQLException

getRef

Ref getRef(int parameterIndex) throws SQLException
Ref getRef(String parameterName) throws SQLException

getRowId

RowId getRowId(int parameterIndex) throws SQLException
RowId getRowId(String parameterName) throws SQLException

getShort

short getShort(int parameterIndex) throws SQLException
short getShort(String parameterName) throws SQLException

getSQLXML

SQLXML getSQLXML(int parameterIndex) throws SQLException
SQLXML getSQLXML(String parameterName) throws SQLException

getString

String getString(int parameterIndex) throws SQLException
String getString(String parameterName) throws SQLException

getTime

Time getTime(int parameterIndex) throws SQLException
Time getTime(int parameterIndex, Calendar cal) throws SQLException
Time getTime(String parameterName) throws SQLException
Time getTime(String parameterName, Calendar cal) throws SQLException

getTimestamp

Timestamp getTimestamp(int parameterIndex) throws SQLException
Timestamp getTimestamp(int parameterIndex, Calendar cal) throws SQLException
Timestamp getTimestamp(String parameterName) throws SQLException
Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLException

getURL

URL getURL(int parameterIndex) throws SQLException
URL getURL(String parameterName) throws SQLException

registerOutParameter

void registerOutParameter(int parameterIndex, int sqlType) throws SQLException
void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException
void registerOutParameter(int parameterIndex, int sqlType, String typeName) throws SQLException
void registerOutParameter(String parameterName, int sqlType) throws SQLException
void registerOutParameter(String parameterName, int sqlType, int scale) throws SQLException
void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException

setAsciiStream

void setAsciiStream(String parameterName, InputStream x) throws SQLException
void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException
void setAsciiStream(String parameterName, InputStream x, long length) throws SQLException

setBigDecimal

void setBigDecimal(String parameterName, BigDecimal x) throws SQLException

setBinaryStream

void setBinaryStream(String parameterName, InputStream x) throws SQLException
void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException
void setBinaryStream(String parameterName, InputStream x, long length) throws SQLException

setBlob

void setBlob(String parameterName, Blob x) throws SQLException
void setBlob(String parameterName, InputStream inputStream) throws SQLException
void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException

setBoolean

void setBoolean(String parameterName, boolean x) throws SQLException

setByte

void setByte(String parameterName, byte x) throws SQLException

setBytes

void setBytes(String parameterName, byte[] x) throws SQLException

setCharacterStream

void setCharacterStream(String parameterName, Reader reader) throws SQLException
void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException
void setCharacterStream(String parameterName, Reader reader, long length) throws SQLException

setClob

void setClob(String parameterName, Clob x) throws SQLException
void setClob(String parameterName, Reader reader) throws SQLException
void setClob(String parameterName, Reader reader, long length) throws SQLException

setDate

void setDate(String parameterName, Date x) throws SQLException
void setDate(String parameterName, Date x, Calendar cal) throws SQLException

setDouble

void setDouble(String parameterName, double x) throws SQLException

setFloat

void setFloat(String parameterName, float x) throws SQLException

setInt

void setInt(String parameterName, int x) throws SQLException

setLong

void setLong(String parameterName, long x) throws SQLException

setNCharacterStream

void setNCharacterStream(String parameterName, Reader value) throws SQLException
void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException

setNClob

void setNClob(String parameterName, NClob value) throws SQLException
void setNClob(String parameterName, Reader reader) throws SQLException
void setNClob(String parameterName, Reader reader, long length) throws SQLException

setNString

void setNString(String parameterName, String value) throws SQLException

setNull

void setNull(String parameterName, int sqlType) throws SQLException
void setNull(String parameterName, int sqlType, String typeName) throws SQLException

setObject

void setObject(String parameterName, Object x) throws SQLException
void setObject(String parameterName, Object x, int targetSqlType) throws SQLException
void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException

setRowId

void setRowId(String parameterName, RowId x) throws SQLException

setShort

void setShort(String parameterName, short x) throws SQLException

setSQLXML

void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException

setString

void setString(String parameterName, String x) throws SQLException

setTime

void setTime(String parameterName, Time x) throws SQLException
void setTime(String parameterName, Time x, Calendar cal) throws SQLException

setTimestamp

void setTimestamp(String parameterName, Timestamp x) throws SQLException
void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException

setURL

void setURL(String parameterName, URL val) throws SQLException

wasNull

boolean wasNull()

isWrapperFor

boolean isWrapperFor(Class<?> iface)

unwrap

boolean isWrapperFor(Class<?> iface)

Clob

free

void free() throws SQLException

getAsciiStream

InputStream getAsciiStream() throws SQLException

getCharacterStream

Reader getCharacterStream() throws SQLException
Reader getCharacterStream(long pos, long length) throws SQLException

getSubString

String getSubString(long pos, int length) throws SQLException

length

long length() throws SQLException

position

long position(Clob searchstr, long start) throws SQLException
long position(String searchstr, long start) throws SQLException

setAsciiStream

OutputStream setAsciiStream(long pos) throws SQLException

setCharacterStream

Writer setCharacterStream(long pos) throws SQLException

setString

int setString(long pos, String str) throws SQLException
int setString(long pos, String str, int offset, int len) throws SQLException

truncate

void truncate(long len) throws SQLException

CommonDataSource

getLoginTimeout

int getLoginTimeout() throws SQLException

getLogWriter

PrintWriter getLogWriter() throws SQLException

setLoginTimeout

void setLoginTimeout(int seconds) throws SQLException

setLogWriter

void setLogWriter(PrintWriter out) throws SQLException

setDataSourceName

void setDataSourceName(String aDataSourceName)

setServerName

void setServerName(String aServerName)

setDatabaseName

void setDatabaseName(String aDBName)

setNetworkProtocol

void setNetworkProtocol(String aProtocol)

setUser

void setUser(String aUser)

setPassword

void setPassword(String aPassword)

setPortNumber

void setPortNumber(int aPort)
void setPortNumber(String aPort)

setRoleName

void setRoleName(String aRoleName)

setDescription

void setDescription(String aDescription)

setConnectionProperties

void setConnectionProperties(Properties aProps)

setURL

void setURL(String aURL) throws SQLException
void setUrl(String aUrl) throws SQLException

setURL(String aURL)과 동일하다.

setLogTarget

void setLogTarget(String aTarget)

setTraceLog

void setTraceLog(String aMode)

setQueryLog

void setQueryLog(String aMode)

setProtocolLog

void setProtocolLog(String aMode)

Connection

clearWarnings

void clearWarnings() throws SQLException

close

void close() throws SQLException

commit

void commit() throws SQLException

createArrayOf

Array createArrayOf(String typeName, Object[] elements) throws SQLException

createBlob

Blob createBlob() throws SQLException

createClob

Clob createClob() throws SQLException

createNClob

NClob createNClob() throws SQLException

createSQLXML

SQLXML createSQLXML() throws SQLException

createStatement

Statement createStatement() throws SQLException
Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException

createStruct

Struct createStruct(String typeName, Object[] attributes) throws SQLException

getAutoCommit

boolean getAutoCommit() throws SQLException

getCatalog

String getCatalog() throws SQLException

getClientInfo

Properties getClientInfo() throws SQLException
String getClientInfo(String name) throws SQLException

getHoldability

int getHoldability() throws SQLException

getMetaData

DatabaseMetaData getMetaData() throws SQLException

getNetworkTimeout

int getNetworkTimeout() throws SQLException

getTransactionIsolation

int getTransactionIsolation() throws SQLException

getTypeMap

Map<String,Class<?>> getTypeMap() throws SQLException

getWarnings

SQLWarning getWarnings() throws SQLException

isClosed

boolean isClosed() throws SQLException

이 method는 실제 서버와의 연결이 끊겼는지 여부는 알려주지 않는다. 실제로 연결이 끊겼더라도 사용자가 close()를 호출한 적이 없다면 false를 반환한다.

isReadOnly

boolean isReadOnly() throws SQLException

isValid

boolean isValid(int timeout) throws SQLException

nativeSQL

String nativeSQL(String sql) throws SQLException

prepareCall

CallableStatement prepareCall(String sql) throws SQLException
CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException

prepareStatement

PreparedStatement prepareStatement(String sql) throws SQLException
PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException

releaseSavepoint

void releaseSavepoint(Savepoint savepoint) throws SQLException

rollback

void rollback() throws SQLException
void rollback(Savepoint savepoint) throws SQLException

setAutoCommit

void setAutoCommit(boolean autoCommit) throws SQLException

setCatalog

void setCatalog(String catalog) throws SQLException

setClientInfo

void setClientInfo(Properties properties) throws SQLException
void setClientInfo(String name, String value) throws SQLException

setHoldability

void setHoldability(int holdability) throws SQLException

setNetworkTimeout

void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException

setReadOnly

void setReadOnly(boolean readOnly) throws SQLException

setSavepoint

Savepoint setSavepoint() throws SQLException
Savepoint setSavepoint(String name) throws SQLException

setTransactionIsolation

void setTransactionIsolation(int level) throws SQLException

setTypeMap

void setTypeMap(Map<String,Class<?>> map) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface) throws SQLException

unwrap

<T> T unwrap(Class<T> iface) throws SQLException

ConnectionPoolDataSource

getPooledConnection

PooledConnection getPooledConnection() throws SQLException
PooledConnection getPooledConnection(String user, String password) throws SQLException

DatabaseMetaData

allProceduresAreCallable

boolean allProceduresAreCallable() throws SQLException

allTablesAreSelectable

boolean allTablesAreSelectable() throws SQLException

autoCommitFailureClosesAllResultSets

boolean autoCommitFailureClosesAllResultSets() throws SQLException

dataDefinitionCausesTransactionCommit

boolean dataDefinitionCausesTransactionCommit() throws SQLException

dataDefinitionIgnoredInTransactions

boolean dataDefinitionIgnoredInTransactions() throws SQLException

deletesAreDetected

boolean deletesAreDetected(int type) throws SQLException

doesMaxRowSizeIncludeBlobs

boolean doesMaxRowSizeIncludeBlobs() throws SQLException

getAttributes

ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException

getBestRowIdentifier

ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException

getCatalogs

ResultSet getCatalogs() throws SQLException

getCatalogSeparator

String getCatalogSeparator() throws SQLException

getCatalogTerm

String getCatalogTerm() throws SQLException

getClientInfoProperties

ResultSet getClientInfoProperties() throws SQLException

getColumnPrivileges

ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException

getColumns

ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException

getConnection

Connection getConnection() throws SQLException

getCrossReference

ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException

getDatabaseMajorVersion

int getDatabaseMajorVersion() throws SQLException

getDatabaseMinorVersion

int getDatabaseMinorVersion() throws SQLException

getDatabaseProductName

String getDatabaseProductName() throws SQLException

getDatabaseProductVersion

String getDatabaseProductVersion() throws SQLException

getDefaultTransactionIsolation

int getDefaultTransactionIsolation() throws SQLException

getDriverMajorVersion

int getDriverMajorVersion() throws SQLException

getDriverMinorVersion

int getDriverMinorVersion() throws SQLException

getDriverName

String getDriverName() throws SQLException

getDriverVersion

String getDriverVersion() throws SQLException

getExportedKeys

ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException

getExtraNameCharacters

String getExtraNameCharacters() throws SQLException

getFunctionColumns

ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException

getFunctions

ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException

getIdentifierQuoteString

String getIdentifierQuoteString() throws SQLException

getImportedKeys

ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException

getIndexInfo

ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException

getJDBCMajorVersion

int getJDBCMajorVersion() throws SQLException

getJDBCMinorVersion

int getJDBCMinorVersion() throws SQLException

getMaxBinaryLiteralLength

int getMaxBinaryLiteralLength() throws SQLException

getMaxCatalogNameLength

int getMaxCatalogNameLength() throws SQLException

getMaxCharLiteralLength

int getMaxCharLiteralLength() throws SQLException

getMaxColumnNameLength

int getMaxColumnNameLength() throws SQLException

getMaxColumnsInGroupBy

int getMaxColumnsInGroupBy() throws SQLException

getMaxColumnsInIndex

int getMaxColumnsInIndex() throws SQLException

getMaxColumnsInOrderBy

int getMaxColumnsInOrderBy() throws SQLException

getMaxColumnsInSelect

int getMaxColumnsInSelect() throws SQLException

getMaxColumnsInTable

int getMaxColumnsInTable() throws SQLException

getMaxConnections

int getMaxConnections() throws SQLException

getMaxCursorNameLength

int getMaxCursorNameLength() throws SQLException

getMaxIndexLength

int getMaxIndexLength() throws SQLException

JDBC 스펙에는 하나의 인덱스 전체가 가질 수 있는 최대 크기를 바이트로 반환한다고 정의하고 있지만 인덱스 크기에는 제한이 없으므로 그 값은 의미가 없고 ODBC와 동일한 의미가 되도록 하기 위해 이와 같이 작동한다.

getMaxProcedureNameLength

int getMaxProcedureNameLength() throws SQLException

getMaxRowSize

int getMaxRowSize() throws SQLException

getMaxSchemaNameLength

int getMaxSchemaNameLength() throws SQLException

getMaxStatementLength

int getMaxStatementLength() throws SQLException

getMaxStatements

int getMaxStatements() throws SQLException

getMaxTableNameLength

int getMaxTableNameLength() throws SQLException

getMaxTablesInSelect

int getMaxTablesInSelect() throws SQLException

getMaxUserNameLength

int getMaxUserNameLength() throws SQLException

getNumericFunctions

String getNumericFunctions() throws SQLException

getPrimaryKeys

ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException

getProcedureColumns

ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException

getProcedures

ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException

getProcedureTerm

String getProcedureTerm() throws SQLException

getResultSetHoldability

int getResultSetHoldability() throws SQLException

getRowIdLifetime

RowIdLifetime getRowIdLifetime() throws SQLException

getSchemas

ResultSet getSchemas() throws SQLException
ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException

getSchemaTerm

String getSchemaTerm() throws SQLException

getSearchStringEscape

String getSearchStringEscape() throws SQLException

getSQLKeywords

String getSQLKeywords() throws SQLException

getSQLStateType

int getSQLStateType() throws SQLException

getStringFunctions

String getStringFunctions() throws SQLException

getSuperTables

ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException

getSuperTypes

ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException

getSystemFunctions

String getSystemFunctions() throws SQLException

getTablePrivileges

ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException

getTables

ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException

getTableTypes

ResultSet getTableTypes() throws SQLException

getTimeDateFunctions

String getTimeDateFunctions() throws SQLException

getTypeInfo

ResultSet getTypeInfo() throws SQLException

getUDTs

ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException

getURL

String getURL() throws SQLException

getUserName

String getUserName() throws SQLException

세션 중에 user를 변경할 수 있기 때문에 처음 접속했을 때의 user name과 다를 수도 있다.

getVersionColumns

ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException

insertsAreDetected

boolean insertsAreDetected(int type) throws SQLException

isCatalogAtStart

boolean isCatalogAtStart() throws SQLException

isReadOnly

boolean isReadOnly() throws SQLException

locatorsUpdateCopy

boolean locatorsUpdateCopy() throws SQLException

nullPlusNonNullIsNull

boolean nullPlusNonNullIsNull() throws SQLException

nullsAreSortedAtEnd

boolean nullsAreSortedAtEnd() throws SQLException

nullsAreSortedAtStart

boolean nullsAreSortedAtStart() throws SQLException

nullsAreSortedHigh

boolean nullsAreSortedHigh() throws SQLException

nullsAreSortedLow

boolean nullsAreSortedLow() throws SQLException

othersDeletesAreVisible

boolean othersDeletesAreVisible(int type) throws SQLException

othersInsertsAreVisible

boolean othersInsertsAreVisible(int type) throws SQLException

othersUpdatesAreVisible

boolean othersUpdatesAreVisible(int type) throws SQLException

ownDeletesAreVisible

boolean ownDeletesAreVisible(int type) throws SQLException

ownInsertsAreVisible

boolean ownInsertsAreVisible(int type) throws SQLException

ownUpdatesAreVisible

boolean ownUpdatesAreVisible(int type) throws SQLException

storesLowerCaseIdentifiers

boolean storesLowerCaseIdentifiers() throws SQLException

storesLowerCaseQuotedIdentifiers

boolean storesLowerCaseQuotedIdentifiers() throws SQLException

storesMixedCaseIdentifiers

boolean storesMixedCaseIdentifiers() throws SQLException

storesMixedCaseQuotedIdentifiers

boolean storesMixedCaseQuotedIdentifiers() throws SQLException

storesUpperCaseIdentifiers

boolean storesUpperCaseIdentifiers() throws SQLException

storesUpperCaseQuotedIdentifiers

boolean storesUpperCaseQuotedIdentifiers() throws SQLException

supportsAlterTableWithAddColumn

boolean supportsAlterTableWithAddColumn() throws SQLException

supportsAlterTableWithDropColumn

boolean supportsAlterTableWithDropColumn() throws SQLException

supportsANSI92EntryLevelSQL

boolean supportsANSI92EntryLevelSQL() throws SQLException

supportsANSI92FullSQL

boolean supportsANSI92FullSQL() throws SQLException

supportsANSI92IntermediateSQL

boolean supportsANSI92IntermediateSQL() throws SQLException

supportsBatchUpdates

boolean supportsBatchUpdates() throws SQLException

supportsCatalogsInDataManipulation

boolean supportsCatalogsInDataManipulation() throws SQLException

supportsCatalogsInIndexDefinitions

boolean supportsCatalogsInIndexDefinitions() throws SQLException

supportsCatalogsInPrivilegeDefinitions

boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException

supportsCatalogsInProcedureCalls

boolean supportsCatalogsInProcedureCalls() throws SQLException

supportsCatalogsInTableDefinitions

boolean supportsCatalogsInTableDefinitions() throws SQLException

supportsColumnAliasing

boolean supportsColumnAliasing() throws SQLException

supportsConvert

boolean supportsConvert() throws SQLException

supportsConvert

boolean supportsConvert(int fromType, int toType) throws SQLException

supportsCoreSQLGrammar

boolean supportsCoreSQLGrammar() throws SQLException

supportsCorrelatedSubqueries

boolean supportsCorrelatedSubqueries() throws SQLException

supportsDataDefinitionAndDataManipulationTransactions

boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException

supportsDataManipulationTransactionsOnly

boolean supportsDataManipulationTransactionsOnly() throws SQLException

supportsDifferentTableCorrelationNames

boolean supportsDifferentTableCorrelationNames() throws SQLException

supportsExpressionsInOrderBy

boolean supportsExpressionsInOrderBy() throws SQLException

supportsExtendedSQLGrammar

boolean supportsExtendedSQLGrammar() throws SQLException

supportsFullOuterJoins

boolean supportsFullOuterJoins() throws SQLException

supportsGetGeneratedKeys

boolean supportsGetGeneratedKeys() throws SQLException

supportsGroupBy

boolean supportsGroupBy() throws SQLException

supportsGroupByBeyondSelect

boolean supportsGroupByBeyondSelect() throws SQLException

supportsGroupByUnrelated

boolean supportsGroupByUnrelated() throws SQLException

supportsIntegrityEnhancementFacility

boolean supportsIntegrityEnhancementFacility() throws SQLException

supportsLikeEscapeClause

boolean supportsLikeEscapeClause() throws SQLException

supportsLimitedOuterJoins

boolean supportsLimitedOuterJoins() throws SQLException

supportsMinimumSQLGrammar

boolean supportsMinimumSQLGrammar() throws SQLException

supportsMixedCaseIdentifiers

boolean supportsMixedCaseIdentifiers() throws SQLException

supportsMixedCaseQuotedIdentifiers

boolean supportsMixedCaseQuotedIdentifiers() throws SQLException

supportsMultipleOpenResults

boolean supportsMultipleOpenResults() throws SQLException

supportsMultipleResultSets

boolean supportsMultipleResultSets() throws SQLException

supportsMultipleTransactions

boolean supportsMultipleTransactions() throws SQLException

supportsNamedParameters

boolean supportsNamedParameters() throws SQLException

supportsNonNullableColumns

boolean supportsNonNullableColumns() throws SQLException

supportsOpenCursorsAcrossCommit

boolean supportsOpenCursorsAcrossCommit() throws SQLException

supportsOpenCursorsAcrossRollback

boolean supportsOpenCursorsAcrossRollback() throws SQLException

supportsOpenStatementsAcrossCommit

boolean supportsOpenStatementsAcrossCommit() throws SQLException

supportsOpenStatementsAcrossRollback

boolean supportsOpenStatementsAcrossRollback() throws SQLException

supportsOrderByUnrelated

boolean supportsOrderByUnrelated() throws SQLException

supportsOuterJoins

boolean supportsOuterJoins() throws SQLException

supportsPositionedDelete

boolean supportsPositionedDelete() throws SQLException

supportsPositionedUpdate

boolean supportsPositionedUpdate() throws SQLException

supportsResultSetConcurrency

boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException

supportsResultSetHoldability

boolean supportsResultSetHoldability(int holdability) throws SQLException

supportsResultSetType

boolean supportsResultSetType(int type) throws SQLException

supportsSavepoints

boolean supportsSavepoints() throws SQLException

supportsSchemasInDataManipulation

boolean supportsSchemasInDataManipulation() throws SQLException

supportsSchemasInIndexDefinitions

boolean supportsSchemasInIndexDefinitions() throws SQLException

supportsSchemasInPrivilegeDefinitions

boolean supportsSchemasInPrivilegeDefinitions() throws SQLException

supportsSchemasInProcedureCalls

boolean supportsSchemasInProcedureCalls() throws SQLException

supportsSchemasInTableDefinitions

boolean supportsSchemasInTableDefinitions() throws SQLException

supportsSelectForUpdate

boolean supportsSelectForUpdate() throws SQLException

supportsStatementPooling

boolean supportsStatementPooling() throws SQLException

supportsStoredFunctionsUsingCallSyntax

boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException

supportsStoredProcedures

boolean supportsStoredProcedures() throws SQLException

supportsSubqueriesInComparisons

boolean supportsSubqueriesInComparisons() throws SQLException

supportsSubqueriesInExists

boolean supportsSubqueriesInExists() throws SQLException

supportsSubqueriesInIns

boolean supportsSubqueriesInIns() throws SQLException

supportsSubqueriesInQuantifieds

boolean supportsSubqueriesInQuantifieds() throws SQLException

supportsTableCorrelationNames

boolean supportsTableCorrelationNames() throws SQLException

supportsTransactionIsolationLevel

boolean supportsTransactionIsolationLevel(int level) throws SQLException

supportsTransactions

boolean supportsTransactions() throws SQLException

supportsUnion

boolean supportsUnion() throws SQLException

supportsUnionAll

boolean supportsUnionAll() throws SQLException

updatesAreDetected

boolean updatesAreDetected(int type) throws SQLException

usesLocalFilePerTable

boolean usesLocalFilePerTable() throws SQLException

usesLocalFiles

boolean usesLocalFiles() throws SQLException

DataSource

getConnection

Connection getConnection() throws SQLException
Connection getConnection(String username, String password) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface) throws SQLException

unwrap

<T> T unwrap(Class<T> iface) throws SQLException

Driver

acceptsURL

boolean acceptsURL(String url) throws SQLException

connect

Connection connect(String url, Properties info) throws SQLException

getMajorVersion

int getMajorVersion() throws SQLException

getMinorVersion

int getMinorVersion() throws SQLException

getPropertyInfo

DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException

jdbcCompliant

boolean jdbcCompliant() throws SQLException

NClob

클래스가 구현되지 않았다.

free

void free() throws SQLException

getAsciiStream

InputStream getAsciiStream() throws SQLException

getCharacterStream

Reader getCharacterStream() throws SQLException
Reader getCharacterStream(long pos, long length) throws SQLException

getSubString

String getSubString(long pos, int length) throws SQLException

length

long length() throws SQLException

position

long position(Clob searchstr, long start) throws SQLException
long position(String searchstr, long start) throws SQLException

setAsciiStream

OutputStream setAsciiStream(long pos) throws SQLException

setCharacterStream

Writer setCharacterStream(long pos) throws SQLException

setString

int setString(long pos, String str) throws SQLException
int setString(long pos, String str, int offset, int len) throws SQLException

truncate

void truncate(long len) throws SQLException

ParameterMetaData

ParameterMetaData 객체는 PreparedStatement.getParameterMetaData()를 통해서 얻을 수 있는데, GOLDILOCKS JDBC의 ParameterMetaData는 in/ out 여부에 대한 정보 외에 타입 등에 관한 정보는 실제 데이터베이스의 정보를 이용하지 않고 기본 타입인 varchar를 기준으로 한다. Prepare된 후에 parameter에 대해 서버로부터 얻을 수 있는 정보는 in/ out 뿐이기 때문이다. 예를 들어, "select * from t1 where a=?"라는 질의문으로 prepare를 할 경우, 조건절에 사용된 parameter의 타입은 정해지지 않은 상태이다. 서버는 기본적으로 varchar 타입이라고 가정할 뿐이다.

getParameterClassName

String getParameterClassName(int param) throws SQLException

getParameterCount

int getParameterCount() throws SQLException

getParameterMode

int getParameterMode(int param) throws SQLException

getParameterType

int getParameterType(int param) throws SQLException

getParameterTypeName

String getParameterTypeName(int param) throws SQLException

getPrecision

int getPrecision(int param) throws SQLException

getScale

int getScale(int param) throws SQLException

isNullable

int isNullable(int param) throws SQLException

isSigned

boolean isSigned(int param) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface) throws SQLException

unwrap

<T> T unwrap(Class<T> iface) throws SQLException

PooledConnection

addConnectionEventListener

void addConnectionEventListener(ConnectionEventListener listener) throws SQLException

addStatementEventListener

void addStatementEventListener(StatementEventListener listener) throws SQLException

close

void close() throws SQLException

getConnection

Connection getConnection() throws SQLException

removeConnectionEventListener

void removeConnectionEventListener(ConnectionEventListener listener) throws SQLException

removeStatementEventListener

void removeStatementEventListener(StatementEventListener listener) throws SQLException

PreparedStatement

addBatch

void addBatch() throws SQLException

clearParameters

void clearParameters() throws SQLException

execute

boolean execute() throws SQLException

executeQuery

ResultSet executeQuery() throws SQLException

executeUpdate

int executeUpdate() throws SQLException

getMetaData

ResultSetMetaData getMetaData() throws SQLException

getParameterMetaData

ParameterMetaData getParameterMetaData() throws SQLException

setArray

void setArray(int parameterIndex, Array x) throws SQLException

setAsciiStream

void setAsciiStream(int parameterIndex, InputStream x) throws SQLException

LONG VARCHAR로 바인딩되기 때문에 서버에서 VARCHAR로 변환 비용이 발생된다. 길이를 알 수 있으면 void setAsciiStream(int parameterIndex, InputStream x, int length)를 사용하는게 좋다.

void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException

setBigDecimal

void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException

setBinaryStream

void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException

setBlob

void setBlob(int parameterIndex, Blob x) throws SQLException
void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException

setBoolean

void setBoolean(int parameterIndex, boolean x) throws SQLException

setByte

void setByte(int parameterIndex, byte x) throws SQLException

setBytes

void setBytes(int parameterIndex, byte[] x) throws SQLException

setCharacterStream

void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException

setClob

void setClob(int parameterIndex, Clob x) throws SQLException
void setClob(int parameterIndex, Reader reader) throws SQLException
void setClob(int parameterIndex, Reader reader, long length) throws SQLException

setDate

void setDate(int parameterIndex, Date x) throws SQLException
void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException

setDouble

void setDouble(int parameterIndex, double x) throws SQLException

setFloat

void setFloat(int parameterIndex, float x) throws SQLException

setInt

void setInt(int parameterIndex, int x) throws SQLException

setLong

void setLong(int parameterIndex, long x) throws SQLException

setNCharacterStream

void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException

setNClob

void setNClob(int parameterIndex, NClob value) throws SQLException
void setNClob(int parameterIndex, Reader reader) throws SQLException
void setNClob(int parameterIndex, Reader reader, long length) throws SQLException

setNString

void setNString(int parameterIndex, String value) throws SQLException

setNull

void setNull(int parameterIndex, int sqlType) throws SQLException
void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException

setObject

void setObject(int parameterIndex, Object x) throws SQLException
Java 객체 → GOLDILOCKS 타입

Java 클래스

GOLDILOCKS 타입

null

VARCHAR

Boolean

BOOLEAN

Byte

NATIVE_SMALLINT

Short

NATIVE_SMALLINT

Integer

NATIVE_INTEGER

Long

NATIVE_BIGINT

Float

NATIVE_REAL

Double

NATIVE_DOUBLE

BigInteger

NATIVE_BIGINT

BigDecimal

NUMBER

String

VARCHAR or LONG VARCHAR

byte[]

VARBINARY or LONG VARBINARY

Date

DATE

Time

TIME

Timestamp

TIMESTAMP

Blob

N/A

Clob

N/A

InputStream

LONG VARBINARY

Reader

LONG VARCHAR

GoldilocksInterval

해당 INTERVAL 타입

RowId

ROWID

그 외

N/A

void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException

setRef

void setRef(int parameterIndex, Ref x) throws SQLException

setRowId

void setRowId(int parameterIndex, RowId x) throws SQLException

setShort

void setShort(int parameterIndex, short x) throws SQLException

setSQLXML

void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException

setString

void setString(int parameterIndex, String x) throws SQLException

setTime

void setTime(int parameterIndex, Time x) throws SQLException
void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException

setTimestamp

void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException

setUnicodeStream

void setUnicodeStream(int parameterIndex, InputStream x, int length) throws SQLException

setURL

void setURL(int parameterIndex, URL x) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface) throws SQLException

unwrap

<T> T unwrap(Class<T> iface) throws SQLException

executeBatchAtomic

boolean executeBatchAtomic() throws SQLException

GOLDILOCKS JDBC의 고유한 기능으로써 PreparedStatement 객체를 GoldilocksPreparedStatement로 캐스팅 한 후에 사용할 수 있다.

예: ((GoldilocksPreparedStatement)pstmt).executeBatchAtomic();

setTimeTimeZone

void setTimeTimeZone(int parameterIndex, Time x, Calendar cal) throws SQLException

GOLDILOCKS JDBC의 고유한 기능으로써 PreparedStatement 객체를 GoldilocksPreparedStatement로 캐스팅 한 후에 사용할 수 있다.

예: ((GoldilocksPreparedStatement)pstmt).setTimeTimeZone(1, aTime, aCalendar);

setTimestampTimeZone

void setTimestampTimeZone(int parameterIndex, Timestamp x, Calendar cal) throws SQLException

GOLDILOCKS JDBC의 고유한 기능으로써 PreparedStatement 객체를 GoldilocksPreparedStatement로 캐스팅 한 후에 사용할 수 있다.

예: ((GoldilocksPreparedStatement)pstmt).setTimestampTimeZone(1, aTimestamp, aCalendar);

Ref

클래스가 구현되지 않았다.

getBaseTypeName

String getBaseTypeName() throws SQLException

getObject

Object getObject() throws SQLException
Object getObject(Map<String,Class<?>> map) throws SQLException

setObject

void setObject(Object value) throws SQLException

ResultSet

absolute

boolean absolute(int row) throws SQLException

캐시 내에 없어서 다시 fetch 해와야 할 때, row가 현재 위치보다 뒤쪽이면, next()에 유리하도록 row 위치부터 n (fetch 할 때 서버로부터 가져오는 row 개수)개를 서버로부터 fetch해오고, row가 현재 위치보다 앞쪽이면, previous()에 유리하도록 (row-n+1) 위치부터 n개를 fetch해온다.

afterLast

void afterLast() throws SQLException

beforeFirst

void beforeFirst() throws SQLException

cancelRowUpdates

void cancelRowUpdates() throws SQLException

clearWarnings

void clearWarnings() throws SQLException

close

void close() throws SQLException

deleteRow

void deleteRow() throws SQLException

findColumn

int findColumn(String columnLabel) throws SQLException

first

boolean first() throws SQLException

getArray

Array getArray(int columnIndex) throws SQLException
Array getArray(String columnLabel) throws SQLException

getAsciiStream

InputStream getAsciiStream(int columnIndex) throws SQLException
InputStream getAsciiStream(String columnLabel) throws SQLException

getBigDecimal

BigDecimal getBigDecimal(int columnIndex) throws SQLException
BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException
BigDecimal getBigDecimal(String columnLabel) throws SQLException
BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException

getBinaryStream

InputStream getBinaryStream(int columnIndex) throws SQLException
InputStream getBinaryStream(String columnLabel) throws SQLException

getBlob

Blob getBlob(int columnIndex) throws SQLException
Blob getBlob(String columnLabel) throws SQLException

getBoolean

boolean getBoolean(int columnIndex) throws SQLException
boolean getBoolean(String columnLabel) throws SQLException

getByte

byte getByte(int columnIndex) throws SQLException
byte getByte(String columnLabel) throws SQLException

getBytes

byte[] getBytes(int columnIndex) throws SQLException

모든 GOLDILOCKS 데이터 타입에 대해 getBytes를 하면 데이터베이스에 저장된 바이너리 형태를 얻는다.

byte[] getBytes(String columnLabel) throws SQLException

모든 GOLDILOCKS 데이터 타입에 대해 getBytes를 하면 데이터베이스에 저장된 바이너리 형태를 얻는다.

getCharacterStream

Reader getCharacterStream(int columnIndex) throws SQLException
Reader getCharacterStream(String columnLabel) throws SQLException

getClob

Clob getClob(int columnIndex) throws SQLException
Clob getClob(String columnLabel) throws SQLException

getConcurrency

int getConcurrency() throws SQLException

getCursorName

String getCursorName() throws SQLException

getDate

Date getDate(int columnIndex) throws SQLException
Date getDate(int columnIndex, Calendar cal) throws SQLException
Date getDate(String columnLabel) throws SQLException
Date getDate(String columnLabel, Calendar cal) throws SQLException

getDouble

double getDouble(int columnIndex) throws SQLException
double getDouble(String columnLabel) throws SQLException

getFetchDirection

int getFetchDirection() throws SQLException

getFetchSize

int getFetchSize() throws SQLException

getFloat

float getFloat(int columnIndex) throws SQLException
float getFloat(String columnLabel) throws SQLException

getHoldability

int getHoldability() throws SQLException

getInt

int getInt(int columnIndex) throws SQLException
int getInt(String columnLabel) throws SQLException

getLong

long getLong(int columnIndex) throws SQLException
long getLong(String columnLabel) throws SQLException

getMetaData

ResultSetMetaData getMetaData() throws SQLException

getNCharacterStream

Reader getNCharacterStream(int columnIndex) throws SQLException
Reader getNCharacterStream(String columnLabel) throws SQLException

getNClob

NClob getNClob(int columnIndex) throws SQLException
NClob getNClob(String columnLabel) throws SQLException

getNString

String getNString(int columnIndex) throws SQLException
String getNString(String columnLabel) throws SQLException

getObject

Object getObject(int columnIndex) throws SQLException
Object getObject(int columnIndex, Map<String,Class<?>> map) throws SQLException
Object getObject(String columnLabel) throws SQLException
Object getObject(String columnLabel, Map<String,Class<?>> map) throws SQLException

getRef

Ref getRef(int columnIndex) throws SQLException
Ref getRef(String columnLabel) throws SQLException

getRow

int getRow() throws SQLException

getRowId

RowId getRowId(int columnIndex) throws SQLException
RowId getRowId(String columnLabel) throws SQLException

getShort

short getShort(int columnIndex) throws SQLException
short getShort(String columnLabel) throws SQLException

getSQLXML

SQLXML getSQLXML(int columnIndex) throws SQLException
SQLXML getSQLXML(String columnLabel) throws SQLException

getStatement

Statement getStatement() throws SQLException

getString

String getString(int columnIndex) throws SQLException
String getString(String columnLabel) throws SQLException

getTime

Time getTime(int columnIndex) throws SQLException
Time getTime(int columnIndex, Calendar cal) throws SQLException
Time getTime(String columnLabel) throws SQLException
Time getTime(String columnLabel, Calendar cal) throws SQLException

getTimestamp

Timestamp getTimestamp(int columnIndex) throws SQLException
Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
Timestamp getTimestamp(String columnLabel) throws SQLException
Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException

getType

int getType() throws SQLException

getUnicodeStream

InputStream getUnicodeStream(int columnIndex) throws SQLException
InputStream getUnicodeStream(String columnLabel) throws SQLException

getURL

URL getURL(int columnIndex) throws SQLException
URL getURL(String columnLabel) throws SQLException

getWarnings

SQLWarning getWarnings() throws SQLException

insertRow

void insertRow() throws SQLException

isAfterLast

boolean isAfterLast() throws SQLException

isBeforeFirst

boolean isBeforeFirst() throws SQLException

isClosed

boolean isClosed() throws SQLException

isFirst

boolean isFirst() throws SQLException

isLast

boolean isLast() throws SQLException

last

boolean last() throws SQLException

moveToCurrentRow

void moveToCurrentRow() throws SQLException

moveToInsertRow

void moveToInsertRow() throws SQLException

next

boolean next() throws SQLException

previous

boolean previous() throws SQLException

refreshRow

void refreshRow() throws SQLException

relative

boolean relative(int rows) throws SQLException

rowDeleted

boolean rowDeleted() throws SQLException

rowInserted

boolean rowInserted() throws SQLException

rowUpdated

boolean rowUpdated() throws SQLException

setFetchDirection

void setFetchDirection(int direction) throws SQLException

setFetchSize

void setFetchSize(int rows) throws SQLException

updateArray

void updateArray(int columnIndex, Array x) throws SQLException
void updateArray(String columnLabel, Array x) throws SQLException

updateAsciiStream

void updateAsciiStream(int columnIndex, InputStream x) throws SQLException
void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException
void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException
void updateAsciiStream(String columnLabel, InputStream x) throws SQLException
void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException
void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException

updateBigDecimal

void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException
void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException

updateBinaryStream

void updateBinaryStream(int columnIndex, InputStream x) throws SQLException
void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException
void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException
void updateBinaryStream(String columnLabel, InputStream x) throws SQLException
void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException
void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException

updateBlob

void updateBlob(int columnIndex, Blob x) throws SQLException
void updateBlob(int columnIndex, InputStream inputStream) throws SQLException
void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException
void updateBlob(String columnLabel, Blob x) throws SQLException
void updateBlob(String columnLabel, InputStream inputStream) throws SQLException
void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException

updateBoolean

void updateBoolean(int columnIndex, boolean x) throws SQLException
void updateBoolean(String columnLabel, boolean x) throws SQLException

updateByte

void updateByte(int columnIndex, byte x) throws SQLException
void updateByte(String columnLabel, byte x) throws SQLException

updateBytes

void updateBytes(int columnIndex, byte[] x) throws SQLException
void updateBytes(String columnLabel, byte[] x) throws SQLException

updateCharacterStream

void updateCharacterStream(int columnIndex, Reader x) throws SQLException
void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException
void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException
void updateCharacterStream(String columnLabel, Reader reader) throws SQLException
void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException
void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException

updateClob

void updateClob(int columnIndex, Clob x) throws SQLException
void updateClob(int columnIndex, Reader reader) throws SQLException
void updateClob(int columnIndex, Reader reader, long length) throws SQLException
void updateClob(String columnLabel, Clob x) throws SQLException
void updateClob(String columnLabel, Reader reader) throws SQLException
void updateClob(String columnLabel, Reader reader, long length) throws SQLException

updateDate

void updateDate(int columnIndex, Date x) throws SQLException
void updateDate(String columnLabel, Date x) throws SQLException

updateDouble

void updateDouble(int columnIndex, double x) throws SQLException
void updateDouble(String columnLabel, double x) throws SQLException

updateFloat

void updateFloat(int columnIndex, float x) throws SQLException
void updateFloat(String columnLabel, float x) throws SQLException

updateInt

void updateInt(int columnIndex, int x) throws SQLException
void updateInt(String columnLabel, int x) throws SQLException

updateLong

void updateLong(int columnIndex, long x) throws SQLException
void updateLong(String columnLabel, long x) throws SQLException

updateNCharacterStream

void updateNCharacterStream(int columnIndex, Reader x) throws SQLException
void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException
void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException
void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException

updateNClob

void updateNClob(int columnIndex, NClob nClob) throws SQLException
void updateNClob(int columnIndex, Reader reader) throws SQLException
void updateNClob(int columnIndex, Reader reader, long length) throws SQLException
void updateNClob(String columnLabel, NClob nClob) throws SQLException
void updateNClob(String columnLabel, Reader reader) throws SQLException
void updateNClob(String columnLabel, Reader reader, long length) throws SQLException

updateNString

void updateNString(int columnIndex, String nString) throws SQLException
void updateNString(String columnLabel, String nString) throws SQLException

updateNull

void updateNull(int columnIndex) throws SQLException
void updateNull(String columnLabel) throws SQLException

updateObject

void updateObject(int columnIndex, Object x) throws SQLException
void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException
void updateObject(String columnLabel, Object x) throws SQLException
void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException

updateRef

void updateRef(int columnIndex, Ref x) throws SQLException
void updateRef(String columnLabel, Ref x) throws SQLException

updateRow

void updateRow() throws SQLException

updateRowId

void updateRowId(int columnIndex, RowId x) throws SQLException
void updateRowId(String columnLabel, RowId x) throws SQLException

updateShort

void updateShort(int columnIndex, short x) throws SQLException
void updateShort(String columnLabel, short x) throws SQLException

updateSQLXML

void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException
void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException

updateString

void updateString(int columnIndex, String x) throws SQLException
void updateString(String columnLabel, String x) throws SQLException

updateTime

void updateTime(int columnIndex, Time x) throws SQLException
void updateTime(String columnLabel, Time x) throws SQLException

updateTimestamp

void updateTimestamp(int columnIndex, Timestamp x) throws SQLException
void updateTimestamp(String columnLabel, Timestamp x) throws SQLException

wasNull

boolean wasNull() throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface)

unwrap

<T> T unwrap(Class<T> iface)

ResultSetMetaData

getCatalogName

String getCatalogName(int column) throws SQLException

getColumnClassName

String getColumnClassName(int column) throws SQLException

getColumnCount

int getColumnCount() throws SQLException

getColumnDisplaySize

int getColumnDisplaySize(int column) throws SQLException

getColumnLabel

String getColumnLabel(int column) throws SQLException

getColumnName

String getColumnName(int column) throws SQLException

getColumnType

int getColumnType(int column) throws SQLException

getColumnTypeName

String getColumnTypeName(int column) throws SQLException

getPrecision

int getPrecision(int column) throws SQLException

getScale

int getScale(int column) throws SQLException

getSchemaName

String getSchemaName(int column) throws SQLException

getTableName

String getTableName(int column) throws SQLException

isAutoIncrement

boolean isAutoIncrement(int column) throws SQLException

isCaseSensitive

boolean isCaseSensitive(int column) throws SQLException

isCurrency

boolean isCurrency(int column) throws SQLException

isDefinitelyWritable

boolean isDefinitelyWritable(int column) throws SQLException

isNullable

int isNullable(int column) throws SQLException

isReadOnly

boolean isReadOnly(int column) throws SQLException

isSearchable

boolean isSearchable(int column) throws SQLException

isSigned

boolean isSigned(int column) throws SQLException

isWritable

boolean isWritable(int column) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface)

unwrap

<T> T unwrap(Class<T> iface)

RowId

equals

boolean equals(Object obj) throws SQLException

getBytes

byte[] getBytes() throws SQLException

hashCode

int hashCode() throws SQLException

toString

String toString() throws SQLException

RowSet

클래스가 구현되지 않았다.

addRowSetListener

void addRowSetListener(RowSetListener listener) throws SQLException

clearParameters

void clearParameters() throws SQLException

execute

void execute() throws SQLException

getCommand

String getCommand() throws SQLException

getDataSourceName

String getDataSourceName() throws SQLException

getEscapeProcessing

boolean getEscapeProcessing() throws SQLException

getMaxFieldSize

int getMaxFieldSize() throws SQLException

getMaxRows

int getMaxRows() throws SQLException

getPassword

String getPassword() throws SQLException

getQueryTimeout

int getQueryTimeout() throws SQLException

getTransactionIsolation

int getTransactionIsolation() throws SQLException

getTypeMap

Map<String,Class<?>> getTypeMap() throws SQLException

getUrl

String getUrl() throws SQLException

getUsername

String getUsername() throws SQLException

isReadOnly

boolean isReadOnly() throws SQLException

removeRowSetListener

void removeRowSetListener(RowSetListener listener) throws SQLException

setArray

void setArray(int i, Array x) throws SQLException

setAsciiStream

void setAsciiStream(int parameterIndex, InputStream x) throws SQLException
void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException
void setAsciiStream(String parameterName, InputStream x) throws SQLException
void setAsciiStream(String parameterName, InputStream x, int length) throws SQLException

setBigDecimal

void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException
void setBigDecimal(String parameterName, BigDecimal x) throws SQLException

setBinaryStream

void setBinaryStream(int parameterIndex, InputStream x) throws SQLException
void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException
void setBinaryStream(String parameterName, InputStream x) throws SQLException
void setBinaryStream(String parameterName, InputStream x, int length) throws SQLException

setBlob

void setBlob(int i, Blob x) throws SQLException
void setBlob(int parameterIndex, InputStream inputStream) throws SQLException
void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException
void setBlob(String parameterName, Blob x) throws SQLException
void setBlob(String parameterName, InputStream inputStream) throws SQLException
void setBlob(String parameterName, InputStream inputStream, long length) throws SQLException

setBoolean

void setBoolean(int parameterIndex, boolean x) throws SQLException
void setBoolean(String parameterName, boolean x) throws SQLException

setByte

void setByte(int parameterIndex, byte x) throws SQLException
void setByte(String parameterName, byte x) throws SQLException

setBytes

void setBytes(int parameterIndex, byte[] x) throws SQLException
void setBytes(String parameterName, byte[] x) throws SQLException

setCharacterStream

void setCharacterStream(int parameterIndex, Reader reader) throws SQLException
void setCharacterStream(int parameterIndex, Reader reader, int length) throws SQLException
void setCharacterStream(String parameterName, Reader reader) throws SQLException
void setCharacterStream(String parameterName, Reader reader, int length) throws SQLException

setClob

void setClob(int i, Clob x) throws SQLException
void setClob(int parameterIndex, Reader reader) throws SQLException
void setClob(int parameterIndex, Reader reader, long length) throws SQLException
void setClob(String parameterName, Clob x) throws SQLException
void setClob(String parameterName, Reader reader) throws SQLException
void setClob(String parameterName, Reader reader, long length) throws SQLException

setCommand

void setCommand(String cmd) throws SQLException

setConcurrency

void setConcurrency(int concurrency) throws SQLException

setDataSourceName

void setDataSourceName(String name) throws SQLException

setDate

void setDate(int parameterIndex, Date x) throws SQLException
void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException
void setDate(String parameterName, Date x) throws SQLException
void setDate(String parameterName, Date x, Calendar cal) throws SQLException

setDouble

void setDouble(int parameterIndex, double x) throws SQLException
void setDouble(String parameterName, double x) throws SQLException

setEscapeProcessing

void setEscapeProcessing(boolean enable) throws SQLException

setFloat

void setFloat(int parameterIndex, float x) throws SQLException
void setFloat(String parameterName, float x) throws SQLException

setInt

void setInt(int parameterIndex, int x) throws SQLException
void setInt(String parameterName, int x) throws SQLException

setLong

void setLong(int parameterIndex, long x) throws SQLException
void setLong(String parameterName, long x) throws SQLException

setMaxFieldSize

void setMaxFieldSize(int max) throws SQLException

setMaxRows

void setMaxRows(int max) throws SQLException

setNCharacterStream

void setNCharacterStream(int parameterIndex, Reader value) throws SQLException
void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException
void setNCharacterStream(String parameterName, Reader value) throws SQLException
void setNCharacterStream(String parameterName, Reader value, long length) throws SQLException

setNClob

void setNClob(int parameterIndex, NClob value) throws SQLException
void setNClob(int parameterIndex, Reader reader) throws SQLException
void setNClob(int parameterIndex, Reader reader, long length) throws SQLException
void setNClob(String parameterName, NClob value) throws SQLException
void setNClob(String parameterName, Reader reader) throws SQLException
void setNClob(String parameterName, Reader reader, long length) throws SQLException

setNString

void setNString(int parameterIndex, String value) throws SQLException
void setNString(String parameterName, String value) throws SQLException

setNull

void setNull(int parameterIndex, int sqlType) throws SQLException
void setNull(int paramIndex, int sqlType, String typeName) throws SQLException
void setNull(String parameterName, int sqlType) throws SQLException
void setNull(String parameterName, int sqlType, String typeName) throws SQLException

setObject

void setObject(int parameterIndex, Object x) throws SQLException
void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException
void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLException
void setObject(String parameterName, Object x) throws SQLException
void setObject(String parameterName, Object x, int targetSqlType) throws SQLException
void setObject(String parameterName, Object x, int targetSqlType, int scale) throws SQLException

setPassword

void setPassword(String password) throws SQLException

setQueryTimeout

void setQueryTimeout(int seconds) throws SQLException

setReadOnly

void setReadOnly(boolean value) throws SQLException

setRef

void setRef(int i, Ref x) throws SQLException

setRowId

void setRowId(int parameterIndex, RowId x) throws SQLException
void setRowId(String parameterName, RowId x) throws SQLException

setShort

void setShort(int parameterIndex, short x) throws SQLException
void setShort(String parameterName, short x) throws SQLException

setSQLXML

void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException
void setSQLXML(String parameterName, SQLXML xmlObject) throws SQLException

setString

void setString(int parameterIndex, String x) throws SQLException
void setString(String parameterName, String x) throws SQLException

setTime

void setTime(int parameterIndex, Time x) throws SQLException
void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException
void setTime(String parameterName, Time x) throws SQLException
void setTime(String parameterName, Time x, Calendar cal) throws SQLException

setTimestamp

void setTimestamp(int parameterIndex, Timestamp x) throws SQLException
void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException
void setTimestamp(String parameterName, Timestamp x) throws SQLException
void setTimestamp(String parameterName, Timestamp x, Calendar cal) throws SQLException

setTransactionIsolation

void setTransactionIsolation(int level) throws SQLException

setType

void setType(int type) throws SQLException

setTypeMap

void setTypeMap(Map<String,Class<?>> map) throws SQLException

setURL

void setURL(int parameterIndex, URL x) throws SQLException

setUrl

void setUrl(String url) throws SQLException

setUsername

void setUsername(String name) throws SQLException

RowSetMetaData

클래스가 구현되지 않았다.

setAutoIncrement

void setAutoIncrement(int columnIndex, boolean property) throws SQLException

setCaseSensitive

void setCaseSensitive(int columnIndex, boolean property) throws SQLException

setCatalogName

void setCatalogName(int columnIndex, String catalogName) throws SQLException

setColumnCount

void setColumnCount(int columnCount) throws SQLException

setColumnDisplaySize

void setColumnDisplaySize(int columnIndex, int size) throws SQLException

setColumnLabel

void setColumnLabel(int columnIndex, String label) throws SQLException

setColumnName

void setColumnName(int columnIndex, String columnName) throws SQLException

setColumnType

void setColumnType(int columnIndex, int SQLType) throws SQLException

setColumnTypeName

void setColumnTypeName(int columnIndex, String typeName) throws SQLException

setCurrency

void setCurrency(int columnIndex, boolean property) throws SQLException

setNullable

void setNullable(int columnIndex, int property) throws SQLException

setPrecision

void setPrecision(int columnIndex, int precision) throws SQLException

setScale

void setScale(int columnIndex, int scale) throws SQLException

setSchemaName

void setSchemaName(int columnIndex, String schemaName) throws SQLException

setSearchable

void setSearchable(int columnIndex, boolean property) throws SQLException

setSigned

void setSigned(int columnIndex, boolean property) throws SQLException

setTableName

void setTableName(int columnIndex, String tableName) throws SQLException

Savepoint

getSavepointId

int getSavepointId() throws SQLException

getSavepointName

String getSavepointName() throws SQLException

SQLData

클래스가 구현되지 않았다.

getSQLTypeName

String getSQLTypeName() throws SQLException

readSQL

void readSQL(SQLInput stream, String typeName) throws SQLException

writeSQL

void writeSQL(SQLOutput stream) throws SQLException

SQLXML

클래스가 구현되지 않았다.

free

void free() throws SQLException

getBinaryStream

InputStream getBinaryStream() throws SQLException

getCharacterStream

Reader getCharacterStream() throws SQLException

getSource

<T extends Source> T getSource(Class<T> sourceClass) throws SQLException

getString

String getString() throws SQLException

setBinaryStream

OutputStream setBinaryStream() throws SQLException

setCharacterStream

Writer setCharacterStream() throws SQLException

setResult

<T extends Result> T setResult(Class<T> resultClass) throws SQLException

setString

void setString(String value) throws SQLException

Statement

addBatch

void addBatch(String sql) throws SQLException

cancel

void cancel() throws SQLException

clearBatch

void clearBatch() throws SQLException

clearWarnings

void clearWarnings() throws SQLException

close

void close() throws SQLException

execute

boolean execute(String sql) throws SQLException
boolean execute(String sql, int autoGeneratedKeys) throws SQLException
boolean execute(String sql, int[] columnIndexes) throws SQLException
boolean execute(String sql, String[] columnNames) throws SQLException

executeBatch

int[] executeBatch() throws SQLException

Batch job들이 한 번에 서버로 전송되어 실행되는 구조가 아니기 때문에 일반 execute()에 비해 성능상 큰 이점은 없다. 빠른 처리를 위해서는 PreparedStatement의 batch execution을 사용하는 것이 좋다.

executeQuery

ResultSet executeQuery(String sql) throws SQLException

execute()와 동작이 조금 다르다. 동일한 SQL 문에 대해 execute() 후 getResultSet()을 하면 서버와 두 번 통신하게 되는데, execute() 할 때는 실행 명령이, getResultSet() 할 때는 fetch 관련 명령이 수행된다. 이에 반해 executeQuery()는 SQL 문이 select 문이라고 가정하고 fetch 할 때까지 한 번의 통신으로 모두 수행한다.

executeUpdate

int executeUpdate(String sql) throws SQLException
int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
int executeUpdate(String sql, int[] columnIndexes) throws SQLException
int executeUpdate(String sql, String[] columnNames) throws SQLException

getConnection

Connection getConnection() throws SQLException

getExplainPlan

String getExplainPlan() throws SQLException

getExplainPlanOption

int getExplainPlanOption() throws SQLException

getFetchDirection

int getFetchDirection() throws SQLException

getFetchSize

int getFetchSize() throws SQLException

getGeneratedKeys

ResultSet getGeneratedKeys() throws SQLException

getMaxFieldSize

int getMaxFieldSize() throws SQLException

getMaxRows

int getMaxRows() throws SQLException

getMoreResults

boolean getMoreResults() throws SQLException
boolean getMoreResults(int current) throws SQLException

getQueryTimeout

int getQueryTimeout() throws SQLException

getResultSet

ResultSet getResultSet() throws SQLException

getResultSetConcurrency

int getResultSetConcurrency() throws SQLException

getResultSetHoldability

int getResultSetHoldability() throws SQLException

getResultSetType

int getResultSetType() throws SQLException

getUpdateCount

int getUpdateCount() throws SQLException

getUpdateRowCount

long getUpdateRowCount() throws SQLException

getWarnings

SQLWarning getWarnings() throws SQLException

isClosed

boolean isClosed() throws SQLException

isPoolable

boolean isPoolable() throws SQLException

setCursorName

void setCursorName(String name) throws SQLException

setEscapeProcessing

void setEscapeProcessing(boolean enable) throws SQLException

setExplainPlanOption

void setExplainPlanOption(int option) throws SQLException

setFetchDirection

void setFetchDirection(int direction) throws SQLException

setFetchSize

void setFetchSize(int rows) throws SQLException

setMaxFieldSize

void setMaxFieldSize(int max) throws SQLException

setMaxRows

void setMaxRows(int max) throws SQLException

setPoolable

void setPoolable(boolean poolable) throws SQLException

setQueryTimeout

void setQueryTimeout(int seconds) throws SQLException

isWrapperFor

boolean isWrapperFor(Class<?> iface) throws SQLException

unwrap

<T> T unwrap(Class<T> iface) throws SQLException

Struct

클래스가 구현되지 않았다.

getAttributes

Object[] getAttributes() throws SQLException

getAttributes

Object[] getAttributes(Map<String,Class<?>> map) throws SQLException

getSQLTypeName

String getSQLTypeName() throws SQLException

XAConnection

getXAResource

XAResource getXAResource() throws SQLException

XADataSource

getXAConnection

XAConnection getXAConnection() throws SQLException
XAConnection getXAConnection(String user, String password) throws SQLException

XAResource

commit

void commit(Xid xid, boolean onePhase) throws XAException

end

void end(Xid xid, int flags) throws XAException

forget

void forget(Xid xid) throws XAException

getTransactionTimeout

int getTransactionTimeout() throws XAException

isSameRM

boolean isSameRM(XAResource xares) throws XAException

prepare

int prepare(Xid xid) throws XAException

recover

Xid[] recover(int flag) throws XAException

rollback

void rollback(Xid xid) throws XAException

setTransactionTimeout

boolean setTransactionTimeout(int seconds) throws XAException

start

void start(Xid xid, int flags) throws XAException

GoldilocksInterval

GoldilocksInterval 객체를 사용하여 GOLDILOCKS의 column에 값을 부여하려면 추가 타입 사용하기를 참조한다.

createIntervalYear

public static GoldilocksInterval createIntervalYear(int yearPrecision, boolean sign, int year) throws SQLException
public static GoldilocksInterval createIntervalYear(int yearPrecision, String year) throws SQLException

createIntervalMonth

public static GoldilocksInterval createIntervalMonth(int monthPrecision, boolean sign, int month) throws SQLException
public static GoldilocksInterval createIntervalMonth(int monthPrecision, String month) throws SQLException

createIntervalYearToMonth

public static GoldilocksInterval createIntervalYearToMonth(int yearPrecision, boolean sign, int year, int month) throws SQLException
public static GoldilocksInterval createIntervalYearToMonth(int yearPrecision, String yearToMonth) throws SQLException

createIntervalDay

public static GoldilocksInterval createIntervalDay(int dayPrecision, boolean sign, int day) throws SQLException
public static GoldilocksInterval createIntervalDay(int dayPrecision, String day) throws SQLException

createIntervalHour

public static GoldilocksInterval createIntervalHour(int hourPrecision, boolean sign, int hour) throws SQLException
public static GoldilocksInterval createIntervalHour(int hourPrecision, String hour) throws SQLException

createIntervalMinute

public static GoldilocksInterval createIntervalMinute(int minutePrecision, boolean sign, int minute) throws SQLException
public static GoldilocksInterval createIntervalMinute(int minutePrecision, String minute) throws SQLException

createIntervalSecond

public static GoldilocksInterval createIntervalSecond(int secondPrecision, int fractionalPrecision, boolean sign, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalSecond(int secondPrecision, int fractionalPrecision, boolean sign, int day, int hour, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalSecond(int secondPrecision, int fractionalPrecision, String second) throws SQLException

createIntervalDayToHour

public static GoldilocksInterval createIntervalDayToHour(int dayPrecision, boolean sign, int day, int hour) throws SQLException
public static GoldilocksInterval createIntervalDayToHour(int dayPrecision, String dayToHour) throws SQLException

createIntervalDayToMinute

public static GoldilocksInterval createIntervalDayToMinute(int dayPrecision, boolean sign, int day, int hour, int minute) throws SQLException
public static GoldilocksInterval createIntervalDayToMinute(int dayPrecision, String dayToMinute) throws SQLException

createIntervalDayToSecond

public static GoldilocksInterval createIntervalDayToSecond(int dayPrecision, int fractionalPrecision, boolean sign, int day, int hour, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalDayToSecond(int dayPrecision, String dayToSecond) throws SQLException

createIntervalHourToMinute

public static GoldilocksInterval createIntervalHourToMinute(int hourPrecision, boolean sign, int hour, int minute) throws SQLException
public static GoldilocksInterval createIntervalHourToMinute(int hourPrecision, boolean sign, int day, int hour, int minute) throws SQLException
public static GoldilocksInterval createIntervalHourToMinute(int hourPrecision, String hourToMinute) throws SQLException

createIntervalHourToSecond

public static GoldilocksInterval createIntervalHourToSecond(int hourPrecision, int fractionalPrecision, boolean sign, int hour, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalHourToSecond(int hourPrecision, int fractionalPrecision, boolean sign, int day, int hour, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalHourToSecond(int hourPrecision, int fractionalPrecision, String hourToSecond) throws SQLException

createIntervalMinuteToSecond

public static GoldilocksInterval createIntervalMinuteToSecond(int minutePrecision, int fractionalPrecision, boolean sign, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalMinuteToSecond(int minutePrecision, int fractionalPrecision, boolean sign, int day, int hour, int minute, int second, int microsecond) throws SQLException
public static GoldilocksInterval createIntervalMinuteToSecond(int minutePrecision, int fractionalPrecision, String minuteToSecond) throws SQLException

getSign

public int getSign()

getYear

public int getYear()

getMonth

public int getMonth()

getAccumulatedMonth

public int getAccumulatedMonth()

getDay

public int getDay()

getHour

public int getHour()

getAccumulatedHour

public int getAccumulatedHour()

getMinute

public int getMinute()

getAccumulatedMinute

public int getAccumulatedMinute()

getSecond

public int getSecond()

getAccumulatedSecond

public int getAccumulatedSecond()

getMicroSecond

public int getMicroSecond()

getAccumulatedMicroSecond

public long getAccumulatedMicroSecond()

getTypeName

public String getTypeName()

getSqlType

public int getSqlType()

toString

public String toString()

GOLDILOCKS Type

상수 정의

public static final int INTERVAL_YEAR;
public static final int INTERVAL_MONTH;
public static final int INTERVAL_DAY;
public static final int INTERVAL_HOUR;
public static final int INTERVAL_MINUTE;
public static final int INTERVAL_SECOND;
public static final int INTERVAL_YEAR_TO_MONTH;
public static final int INTERVAL_DAY_TO_HOUR;
public static final int INTERVAL_DAY_TO_MINUTE;
public static final int INTERVAL_DAY_TO_SECOND;
public static final int INTERVAL_HOUR_TO_MINUTE;
public static final int INTERVAL_HOUR_TO_SECOND;
public static final int INTERVAL_MINUTE_TO_SECOND;
public static final int TIME_WITH_TIME_ZONE;
public static final int TIMESTAMP_WITH_TIME_ZONE;

이 상수들은 java.sql.Types의 상수처럼 사용된다. 즉, PreparedStatement의 setObject나 ResultSet의 getObject에 타입을 명시할 때 사용된다. 이 타입들은 JDBC 표준에는 정의되어 있지 않으므로 GoldilocksTypes를 통해 별도로 제공된다.

타입 변환

다음 표는 타입 변환 방법을 설명한다.

SQL 타입 → GOLDILOCKS 타입

SQL 타입

GOLDILOCKS 타입

Types.BIGINT

NATIVE_BIGINT

Types.BINARY

BINARY(2000)

Types.BIT

BOOLEAN

Types.BOOLEAN

BOOLEAN

Types.BLOB

LONG VARBINARY

Types.CHAR

CHAR(2000)

Types.CLOB

LONG VARCHAR

Types.DATE

DATE

Types.DECIMAL

DECIMAL

Types.DOUBLE

NATIVE_DOUBLE

Types.FLOAT

FLOAT

Types.NUMERIC

NUMBER

Types.INTEGER

NATIVE_INTEGER

Types.LONGVARBINARY

LONG VARBINARY

Types.LONGVARCHAR

LONG VARCHAR

Types.REAL

NATIVE_REAL

Types.ROWID

ROWID

Types.SMALLINT

NATIVE_SMALLINT

Types.TIME

TIME

Types.TIMESTAMP

TIMESTAMP

Types.VARBINARY

VARBINARY(4000)

Types.VARCHAR

VARCHAR(4000)

GoldilocksTypes.INTERVAL_YEAR

INTERVAL YEAR

GoldilocksTypes.INTERVAL_MONTH

INTERVAL MONTH

GoldilocksTypes.INTERVAL_YEAR_TO_MONTH

INTERVAL YEAR TO MONTH

GoldilocksTypes.INTERVAL_DAY

INTERVAL DAY

GoldilocksTypes.INTERVAL_HOUR

INTERVAL HOUR

GoldilocksTypes.INTERVAL_MINUTE

INTERVAL MINUTE

GoldilocksTypes.INTERVAL_SECOND

INTERVAL SECOND

GoldilocksTypes.INTERVAL_DAY_TO_HOUR

INTERVAL DAY TO HOUR

GoldilocksTypes.INTERVAL_DAY_TO_MINUTE

INTERVAL DAY TO MINUTE

GoldilocksTypes.INTERVAL_DAY_TO_SECOND

INTERVAL DAY TO SECOND

GoldilocksTypes.INTERVAL_HOUR_TO_MINUTE

INTERVAL HOUR TO MINUTE

GoldilocksTypes.INTERVAL_HOUR_TO_SECOND

INTERVAL HOUR TO SECOND

GoldilocksTypes.INTERVAL_MINUTE_TO_SECOND

INTERVAL MINUTE TO SECOND

Types.OTHER

N/A

Types.ARRAY

N/A

Types.DATALINK

N/A

Types.DISTINCT

N/A

Types.NCHAR

N/A

Types.NCLOB

N/A

Types.NVARCHAR

N/A

Types.JAVA_OBJECT

N/A

Types.REF

N/A

Types.SQLXML

N/A

Types.STRUCT

N/A

GOLDILOCKS 타입에 대한 getter method 지원 여부-1


NATIVE_SMALLINT

NATIVE_INTEGER

NATIVE_BIGINT

NATIVE_REAL

NATIVE_DOUBLE

getByte

O

O

O

O

O

getShort

O

O

O

O

O

getInt

O

O

O

O

O

getLong

O

O

O

O

O

getFloat

O

O

O

O

O

getDouble

O

O

O

O

O

getBigDecimal

O

O

O

O

O

getBoolean

0,1일 경우만 가능

0,1일 경우만 가능

0,1일 경우만 가능

0,1일 경우만 가능

0,1일 경우만 가능

getString

O

O

O

O

O

getBytes

raw 데이터

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getDate

X

X

X

X

X

getTime

X

X

X

X

X

getTimestamp

X

X

X

X

X

getAsciiStream

raw 데이터

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getBinaryStream

raw 데이터

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getCharacterStream

X

X

X

X

X

getClob

O

O

O

O

O

getBlob

raw 데이터

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getArray

X

X

X

X

X

getRef

X

X

X

X

X

getURL

X

X

X

X

X

getObject

Short

Integer

Long

Float

Double

getRowId

X

X

X

X

X

GOLDILOCKS 타입에 대한 getter method 지원 여부-2


BOOLEAN

FLOAT/

NUMBER

CHAR/

VARCHAR/

LONG VARCHAR

BINARY/

VARBINARY/LONG VARBINARY

ROWID

getByte

0 or 1

O

숫자일 경우만 가능

X

X

getShort

0 or 1

O

숫자일 경우만 가능

X

X

getInt

0 or 1

O

숫자일 경우만 가능

X

X

getLong

0 or 1

O

숫자일 경우만 가능

X

X

getFloat

0 or 1

O

숫자일 경우만 가능

X

X

getDouble

0 or 1

O

숫자일 경우만 가능

X

X

getBigDecimal

0 or 1

O

숫자일 경우만 가능

X

X

getBoolean

O

0,1일 경우만 가능

"t", "f", "true", "false", "y", "n", "yes", "no", "on", "off", "1", "0" 일 경우만 가능 (대소문자구별안함)

X

X

getString

"TRUE" or "FALSE"

O

O

O

O

getBytes

raw 데이터

raw 데이터

raw 데이터

O

raw 데이터

getDate

X

X

Date format일 경우만 가능

X

X

getTime

X

X

Time format일 경우만 가능

X

X

getTimestamp

X

X

Timestamp format일 경우만 가능

X

X

getAsciiStream

raw 데이터

raw 데이터

raw 데이터

O

raw 데이터

getBinaryStream

raw 데이터

raw 데이터

raw 데이터

O

raw 데이터

getCharacterStream

X

X

O

X

X

getClob

"TRUE" or "FALSE"

O

O

O

O

getBlob

raw 데이터

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getArray

X

X

X

X

X

getRef

X

X

X

X

X

getURL

X

X

X

X

X

getObject

Boolean

BigDecimal

String

byte[]

RowId

getRowId

X

X

X

X

O

GOLDILOCKS 타입에 대한 getter method 지원 여부-3


DATE

TIME/

TIME WITH TIME ZONE

TIMESTAMP/

TIMESTAMP

WITH TIME ZONE

INTERVAL

getByte

X

X

X

단일 항목 타입만 가능

getShort

X

X

X

단일 항목 타입만 가능

getInt

X

X

X

단일 항목 타입만 가능

getLong

X

X

X

단일 항목 타입만 가능

getFloat

X

X

X

단일 항목 타입만 가능

getDouble

X

X

X

단일 항목 타입만 가능

getBigDecimal

X

X

X

단일 항목 타입만 가능

getBoolean

X

X

X

X

getString

O

O

O

O

getBytes

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getDate

O

O

O

X

getTime

O

O

O

X

getTimestamp

O

O

O

X

getAsciiStream

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getBinaryStream

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getCharacterStream

X

X

X

X

getClob

O

O

O

O

getBlob

raw 데이터

raw 데이터

raw 데이터

raw 데이터

getArray

X

X

X

X

getRef

X

X

X

X

getURL

X

X

X

X

getObject

Date

Time

Timestamp

GoldilocksInterval

getRowId

X

X

X

X