- yagom's blog
- 배움에 길에는 끝이 없다.
- Naked Foot
- SAP PP
- SAP ABAP
- SAP BSP
- SAP Inside
- 자바지기
- SECRET OF KOREA
- X-Mobile User Interface World
- 대한민국 자식연합
- 대한민국 토리스토리
- Malus domestica
- PCPINSIDE(거리로 PC, 거실로 PC)
- My Eyes on You
- 조대협의 블로그
- 릴리펏's Logbook
- Dr. Ann(닥터앤)의 DB이야기
- 디지털을 말한다. By oojoo
- Slow Adopter
- T.B 의 SNS 이야기
- Sense and Sensibility
- 언제나 Burning~
- 바스토프의 세상이야기
- Edu&Story
- Min.Gun
- freestation
- nigh
- Programmer
- Shine A Light
- 하루 벌어 하루 살아요. ㅋㅋ
- 아이캐리즈
- 오라클 성능 문제에 대한 통찰 - 조동욱
- 에너쓰오라클
- Science of DataBase
- 기억을 글로 담기
- 홍기선's 아키텍트 이야기 그리고
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
- zero rating
- data pump
- EA
- Annualized Failure Rate
- aws
- cluster table
- nested loops join
- Table
- OUTER JOIN
- MTBF
- index-organized table
- ERP
- semi join
- oracle tuning
- ansi query
- Mean Time Between Failures
- 스폰서 요금제
- RBM
- Network Neutrality
- Database
- oracle
- tuning
- PostgreSQL
- Analytic Function
- A2P
- ORACLE SQL
- AWS Elastic Beanstalk
- MSSQL SQL
- JDBC
- java
- Today
- Total
아이짱구
Oracle 10g CLOB 처리 본문
10g 오라클 이전에는 EMPTY_CLOB()를 이용하던 것을 10g에서는 Standard API로 CLOB을 사용할 수 있도록 수정 되었다고 합니다.
1. Properties 사용하여 clob 입력
import java.sql.Connection;
import java.sql.DriverManager;
import oracle.jdbc.OracleDriver;
import java.util.Properties;
..........
// Load the database details into the variables.
String url = "jdbc:oracle:thin:@localhost:1521:orcl";
String user = "scott";
String password = "tiger";
// Create the properties object that holds all database details
Properties props = new Properties();
props.put("user", user );
props.put("password", password);
props.put("SetBigStringTryClob", "true");
// Load the Oracle JDBC driver class.
DriverManager.registerDriver(new OracleDriver());
// Get the database connection
Connection conn = DriverManager.getConnection( this.url, this.props );
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO clob_tab VALUES(?)");
// Read a big file(larger than 32765 bytes).
// Note: method readFile() not listed here.
// It can be any method that reads a file.
String str = this.readFile("bigFile.txt");
// The string data is automatically transformed into a CLOB and
// inserted into the database column.
// Make sure that the Connection property - 'SetBigStringTryClob' is
// set to true for the insert to happen.
pstmt.setString(1, str);pstmt.executeUpdate();
2. OraclePreparedStatement를 사용하여 CLOB 사용
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.*;
..........
// Create SQL query to insert CLOB data and other columns in the database.
String sql = "INSERT INTO clob_tab VALUES(?)";
// Read a big file(larger than 32765 bytes).
// Note: method readFile() not listed here.
// It can be any method that reads a file.
String str = this.readFile("bigFile.txt");
// Create the OraclePreparedStatement object
opstmt = (OraclePreparedStatement)conn.prepareStatement(sql);
// Use the new method to insert the CLOB data (for data greater or lesser than 32 KB)
opstmt.setStringForClob(1,str);
// Execute the OraclePreparedStatement
opstmt.executeUpdate();
...........
3. CLOB 데이터 가져오기
.....
// Create a PreparedStatement object
PreparedStatement pstmt = null;
// Create a ResultSet to hold the records retrieved.
ResultSet rset = null;
.......
// Create SQL query statement to retrieve records having CLOB data from
// the database.
String sqlCall = "SELECT clob_col FROM clob_tab";
pstmt= conn.prepareStatement(sqlCall);
// Execute the PrepareStatement
rset = pstmt.executeQuery();
String clobVal = null;
// Get the CLOB value larger than 32765 bytes from the resultset
while (rset.next())
{
clobVal = rset.getString(1);
System.out.println("CLOB length: "+clobVal.length());
}
출처: 잊어 먹었어요.