2016. 11. 14. 09:09
import java.io.File; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; public class Main { public static void main(String[] argv) throws Exception { File file = new File("myimage.gif"); FileInputStream fis = new FileInputStream(file); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@//server.local:1521/prod", "scott", "tiger"); conn.setAutoCommit(false); PreparedStatement ps = conn .prepareStatement("insert into images values (?,?)"); ps.setString(1, file.getName()); ps.setBinaryStream(2, fis, (int) file.length()); ps.executeUpdate(); ps.close(); fis.close(); } }
'Java' 카테고리의 다른 글
java 대용량 엑셀업로드 셀타입 처리 (0) | 2019.07.16 |
---|---|
Read BLOBs data from database (0) | 2016.11.14 |
JAVA SPRING + MYBATIS + ORACLE TXT 파일 BLOB 형태로 DB에 INSERT (0) | 2016.11.01 |
java 배열 내 문자열 확인 (0) | 2016.10.04 |
대용량 엑셀파일 업로드 excel upload (4) | 2016.09.22 |