Connection conn = null; PreparedStatement pstmt = null; ResultSet rs = null; try{ conn = ............. String sql = ""; int t_int = 1; String t_clob = "clob data 한글 입력"; sql = " insert into test_clob (t_int, t_clob)values(?, ?) "; pstmt = conn.prepareStatement(sql); pstmt.setInt(1, t_int); pstmt.setAsciiStream(2, new ByteArrayInputStream(t_clob.getBytes()), t_clob.getBytes().length); int result = pstmt.executeUpdate(); out.print("
result: " + result); sql = " select * from test_clob "; pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); if( rs.next() ){ do{ InputStream is2 = rs.getAsciiStream(2); StringBuffer sb = new StringBuffer(); if( is2 != null ){ byte[] b = new byte[4096]; for (int n; (n = is2.read(b)) != -1;) { sb.append(new String(b, 0, n)); } } out.print("
int: " + rs.getInt(1) + " | clob: " + sb); }while( rs.next() ); } }catch(Exception e){ out.print("
e: " + e); }
인포믹스(informix) clob insert
2010. 11. 11. 11:47