connection 후 1천만 건을 insert 하였습니다. 테이블은 만든 상태이고여..
근데 insert 를 하다보면. 몇천건을 쓰다 몇만건을 쓰다
cannot communicate with the broker 라고 발생하면서 broker 하고 연결이 disconnect 됩니다.
문제점이 무엇인지요??
cubrid_broker.conf 에 keep_connection 도 on으로 변경 했는데 마찬가지거든요..
jdbc 를 사용합니다.
public static void main(String[] args) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
try{
Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
conn = DriverManager.getConnection("jdbc:CUBRID:localhost:33000:test:::", "test", "testdb");
int count = 0;
while(count < 10000000){
String sql = insert into test_tbl ( code, sex, name ) values ( ?, ?, ? )" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ""+System.nanoTime());
pstmt.setInt(2, 1);
pstmt.setBytes(3, "11111".getBytes());
int row = pstmt.executeUpdate();
if ( row > 0 ){
conn.commit();
count++;
}
}
stmt.close();
conn.close();
} catch ( SQLException e ) {
System.err.println(e.getMessage());
} catch ( Exception e ) {
System.err.println(e.getMessage());
} finally {
if ( conn != null ) conn.close();
}
}
근데 insert 를 하다보면. 몇천건을 쓰다 몇만건을 쓰다
cannot communicate with the broker 라고 발생하면서 broker 하고 연결이 disconnect 됩니다.
문제점이 무엇인지요??
cubrid_broker.conf 에 keep_connection 도 on으로 변경 했는데 마찬가지거든요..
jdbc 를 사용합니다.
public static void main(String[] args) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
try{
Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
conn = DriverManager.getConnection("jdbc:CUBRID:localhost:33000:test:::", "test", "testdb");
int count = 0;
while(count < 10000000){
String sql = insert into test_tbl ( code, sex, name ) values ( ?, ?, ? )" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ""+System.nanoTime());
pstmt.setInt(2, 1);
pstmt.setBytes(3, "11111".getBytes());
int row = pstmt.executeUpdate();
if ( row > 0 ){
conn.commit();
count++;
}
}
stmt.close();
conn.close();
} catch ( SQLException e ) {
System.err.println(e.getMessage());
} catch ( Exception e ) {
System.err.println(e.getMessage());
} finally {
if ( conn != null ) conn.close();
}
}
CUBRID 상세 버전을 알려 주시기 바랍니다.
내부에서 현재 버전인 2008 R2.0에서 테스트 한 결과 30만건이 들어 가는 동안에도 에러가 발생하지 않고 있습니다.
broker 설정은 디폴트로 설정된 상태 그대로 사용하였습니다.
참고로 아래는 제가 테스트한 소스입니다. 테이블은 create table test_tbl(code varchar(50), sex int, name bit varying(20));으로 생성했습니다. 테스트 하신 내용과 다른 부분이 있으시면 알려 주시기 바랍니다.
import java.sql.*;
public class INSERT {
public static void main(String[] args) throws Exception{
Connection conn = null;
PreparedStatement pstmt = null;
try{
Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
conn = DriverManager.getConnection("jdbc:CUBRID:localhost:36000:demodb:::", "", "");
int count = 0;
while(count < 10000000){
String sql = "insert into test_tbl ( code, sex, name ) values ( ?, ?, ? )" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, ""+System.nanoTime());
pstmt.setInt(2, 1);
pstmt.setBytes(3, "11111".getBytes());
int row = pstmt.executeUpdate();
if ( row > 0 ){
conn.commit();
count++;
}
}
pstmt.close();
conn.close();
} catch ( SQLException e ) {
System.err.println(e.getMessage());
} catch ( Exception e ) {
System.err.println(e.getMessage());
} finally {
if ( conn != null ) conn.close();
}
}
}