package db.common;
import java.sql.Clob;
import java.sql.Connection;
import oracle.jdbc.driver.OracleConnection;
import com.caucho.sql.UserConnectionAdapter;
import com.javaservice.jennifer.trace.sql.Connection4Oracle;
public class DaoHelper {
private DaoHelper(){};
public static int getPageMinNum(int pageSize, int curPage){
int minNum = (curPage * pageSize ) - (pageSize-1); //시작
return minNum;
}
public static int getPageMaxNum(int pageSize, int curPage){
int maxNum = curPage * pageSize ;
//curPage * pageSize; //끝
return maxNum;
}
/**
* oracle의 CLOB을 이용하여 java의 Clob을 생성한다.
*
* @param clobValue
* @param conn
* @return
* @throws Exception
*/
public static Clob getClob(String clobValue, Connection conn) throws Exception{
Clob newClob= null;
if(clobValue!=null) {
try{
if (conn.getClass() == UserConnectionAdapter.class) { //env: resin pool connection
newClob = oracle.sql.CLOB.createTemporary(
((UserConnectionAdapter)conn).getConnection() ,
true, oracle.sql.CLOB.DURATION_SESSION);
} else if (conn.getClass() == OracleConnection.class) { //env: oracle connection
newClob = oracle.sql.CLOB.createTemporary(
conn,
true, oracle.sql.CLOB.DURATION_SESSION);
} else if (conn.getClass() == Connection4Oracle.class) { //env: jennifer connection
conn = ((Connection4Oracle)conn).getNativeConnection();
newClob = oracle.sql.CLOB.createTemporary(
((UserConnectionAdapter)conn).getConnection(),
true, oracle.sql.CLOB.DURATION_SESSION);
} else { //env: else connection
newClob = oracle.sql.CLOB.createTemporary(
conn,
true, oracle.sql.CLOB.DURATION_SESSION);
}
if(newClob!=null) {
((oracle.sql.CLOB)newClob).putString(1, clobValue);
}
} catch (Exception e){
e.printStackTrace();
}
}
return newClob;
}
}
이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받고 있습니다.
이 포스팅은 제휴마케팅이 적용되어 작성자에게 일정액의 커미션이 제공될수 있습니다.
이 글을 공유하기