Javascript

blob 이미지 파일 저장

damian 2012. 11. 26. 15:27

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.util.*, java.sql.*, java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
String sql = "";
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
 
 try {
  con = DriverManager.getConnection("jdbc:oracle:thin:@ip:port","userid","password");
  stmt = con.createStatement();
  rs = stmt.executeQuery("select file_path, file_name, blob_col from table where ..." );
  while(rs.next()){
   String file_path =rs.getString("file_path");
   String file_name="";
  
   if(file_path != null &&  !file_path.equals("") ){
    file_name =rs.getString("file_name");
  
    FileOutputStream outstream =new FileOutputStream("E:\\temp\\"+file_name);
  
    byte[] buffer =rs.getBytes("blob_col");
  
    outstream.write(buffer);
    outstream.close();
   }
  
  }
 } catch(Exception e) {
   out.print(e);
 } finally {
    try {if (rs != null)  rs.close(); } catch (Exception ex) {}
    try {if (stmt != null) stmt.close();} catch (Exception ex) {}
    try {if (con != null) con.close();}  catch (Exception ex) {}
 }
     
%>

</body>
</html>

'Javascript' 카테고리의 다른 글

DISABLE CTRL+SCROLL to Zoom IE with Javascript  (0) 2014.09.28
egov list 를 json 객체로 전달 및 사용  (0) 2014.09.23
이미지 Resizing  (0) 2012.11.26
테이블 객체  (0) 2012.01.25
SetComma  (0) 2012.01.19