else if (db_type.equals(_ORACLE))
{
bf.append(" insert into PS060MEDIMT01 ( \n");
bf.append(" IMAGE_NUM, TITLE, CONTENTS, MEMBER_NUM \n");
bf.append(" , CREATEDON, CATEGORY1, CATEGORY_NUM, \n");
bf.append(" PRIVATE_CATEGORY_NUM, MAINIMAGE, VIEWCOUNT \n");
bf.append(" , ISDEL, ISOPEN, ALBUM_TYPE, ISCONTEST ) \n");
bf.append(" values ( ?, ?, EMPTY_CLOB(), ?, ");
bf.append(getServerTimeString()).append(", ?, ?, \n");
bf.append(" ?, ?, ?, 'N', ?, ?, 'N' ) ");
}
if (db_type.equals(_ORACLE) && iAffected > 0)
{
String[] fieldValues =
{ htmlinputfilter.filter(getPram("content_desc", true), true, false, false) };
String[] fileds =
{ "CONTENTS" };
String clobwhere = "IMAGE_NUM = " + nMaxNo;
insertClob(fileds, fieldValues, "PS060MEDIMT01", clobwhere);
}
/**
* CLOB데이터를 입력할때 사용합니다.
* @since
* @param fieldNames 배열로 입력함, 디비필드의 이름, 건의사항있을시 ' , ' 로 split하겠음
* @param fieldValues 배열로 입력함, 폼객체의 값, 건의사항있을시 ' , ' 로 split하겠음
* @param tablename clob데이터를 입력할 테이블명
* @param clobwhere insert된 행을 가져올 조건
* @throws SQLException
* @throws IOException
*/
protected void insertClob(String[] fieldNames, String[] fieldValues, String tablename
, String clobwhere) throws Exception
{
StringBuffer updateQuery = new StringBuffer();
PreparedStatement pstmtClob = null;
ResultSet rsClob = null;
try
{
updateQuery.append("select ");
for (int i = 0; i < fieldNames.length; i++)
{
if (i != 0)
{
updateQuery.append(", ");
}
updateQuery.append(fieldNames[i].toUpperCase());
}
updateQuery.append(" from ").append(tablename).append(" where ");
updateQuery.append(clobwhere).append(" for update ");
pstmtClob = conn.prepareStatement(updateQuery.toString());
rsClob = pstmtClob.executeQuery();
while (rsClob.next())
{
for (int i = 0; i < fieldNames.length; i++)
{
CLOB clob = null;
if (rsClob instanceof OracleResultSet)
{
clob = ((OracleResultSet) rsClob).getCLOB(i + 1);
} else
{
clob = (CLOB) rsClob.getClob(i + 1);
}
if (clob != null)
{
Writer writer = null;
// TODO WAS추가시 주석 제거해줄것
/*
* if (
* properties.getProperty("clobType").equals("weblogic8"
* ) ) { //weblogic7 / weblogic8 writer =
* ((weblogic.jdbc.common.OracleClob)
* clob).getCharacterOutputStream(); } else if (
* properties
* .getProperty("clobType").equals("weblogic9") ) { //
* weblogic9 writer =
* ((weblogic.jdbc.vendor.oracle.OracleThinClob)
* clob).getCharacterOutputStream(); } else { // resin /
* jeus / tomcat
*/
writer = clob.getCharacterOutputStream();
// }
String sRealValue = "";
if (fieldValues==null||fieldValues[i]==null||fieldValues[i].equals(""))
{
// 오라클 사용관련 수정 - 소스와 db간의 명명규칙 상이
// sRealValue = getPram(fieldNames[i]);
sRealValue = getPram("content");
} else
{
sRealValue = fieldValues[i];
}
Reader src = new CharArrayReader(sRealValue.toCharArray());
// Reader src = new
// CharArrayReader(Ub.replace(sRealValue,"''","'").toCharArray());
char[] buffer = new char[1024];
int read = 0;
read = src.read(buffer, 0, 1024);
while (read != -1)
{
writer.write(buffer, 0, read); // write clob.
read = src.read(buffer, 0, 1024);
}
src.close();
writer.close();
}
}
}
rsClob.close();
pstmtClob.close();
} catch (Exception e)
{
log.error(e.getMessage());
throw new Exception();
} finally
{
if (rsClob != null)
{
try
{
rsClob.close();
}catch(Exception e)
{
log.error(e.getMessage());
throw e;
}
}
rsClob = null;
if (pstmtClob != null)
{
try
{
pstmtClob.close();
} catch(Exception e)
{
log.error(e.getMessage());
throw e;
}
}
}
}