자바에서 LongRaw 예
--------------------------
오라클자바커뮤니티에서 설립한 오엔제이프로그래밍
실무교육센터
(오라클SQL, 튜닝, 힌트,자바프레임워크, 안드로이드, 아이폰, 닷넷 실무전문 강의)
1. 읽을때(detail이란 컬럼이 longraw 입니다.)
try{
InputStream vIcode =null;
BufferedReader vvcode =null;
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(" select name,title,detail,re_id,ip,count,to_char(ilsi,'dd/MON/yyyy(hh:mi)'),path,e_mail,root_id,depth from db_board where id = "+szID);
rs.next();
szName = rs.getString(1);
szTitle = rs.getString(2);
szDetail= hangul.han(new String(rs.getBytes(3),0));
szRe_Id = rs.getString(4);
szIp = rs.getString(5);
iCount = rs.getInt(6);
szIlsi = rs.getString(7);
szPath = rs.getString(8);
szE_mail = rs.getString(9);
szRoot_Id = rs.getString(10);
szDepth = rs.getString(11);
iCount++;
rs.close();
stmt.executeUpdate(" update db_board set count=count+1 where id = "+szID);
stmt.close();
}
2. 저장하는 예
PreparedStatement ps = con.prepareStatement("insert into db_board(id,re_id,name,title,detail,passwd,count,ip,ilsi,e_mail,is_re,board_gbn,path,root_id,depth) values (?,0,?,?,?,?,0,?,sysdate,?,'N',?,?,?,0)");
ps.setInt(1,iId);
ps.setString(2,hangul.han(szName));
ps.setString(3,hangul.han(szTitle));
//////////////////////////////////////////////////////////////////////////
StringBuffer szbWriteDetail = new StringBuffer();
for( int i = 0,len=szDetail.length() ; i < len ; i++){
if( szDetail.charAt(i) == ' ')
szbWriteDetail.append(" ");
else if( szDetail.charAt(i) == '<')
szbWriteDetail.append("<");
else if( szDetail.charAt(i) == '>')
szbWriteDetail.append(">");
else if( szDetail.charAt(i) == '\n')
szbWriteDetail.append("<br>");
else
szbWriteDetail.append(szDetail.charAt(i));
}
////////////////////////////////////////////////////////////////////////////
StringBufferInputStream abc = new StringBufferInputStream(szbWriteDetail.toString());
ps.setBinaryStream(4,abc,szbWriteDetail.length());
ps.setString(5,szPasswd);
ps.setString(6,szIp);
ps.setString(7,szE_mail);
ps.setString(8,szBoard_Gbn);
ps.setString(9,szPath);
ps.setInt(10,iId);
ps.executeUpdate( );
댓글 없음:
댓글 쓰기