-
-
public PagedStatement(String sql){ -
this(sql,1,MAX_PAGE_SIZE); -
} -
-
public PagedStatement(String sql, int pageNo){ -
this(sql, pageNo, Page.DEFAULT_PAGE_SIZE); -
} -
-
public PagedStatement(String sql, int pageNo, int pageSize){ -
this.pageNo = pageNo; -
this.pageSize = pageSize; -
this.startIndex = Page.getStartOfAnyPage(pageNo, pageSize); -
this.boundParams = Collections.synchronizedList(new java.util.LinkedList()); -
this.countSQL = "select count(*) from ( " + sql +") "; -
this.querySQL = intiQuerySQL(sql, this.startIndex, pageSize); -
} -
-
protected abstract String intiQuerySQL(String sql, int startIndex, int size); -
-
public void setObject(int index, Object obj) throws SQLException{ -
BoundParam bp = new BoundParam(index, obj); -
boundParams.remove(bp); -
boundParams.add( bp); -
} -
-
public void setObject(int index, Object obj, int targetSqlType) throws SQLException{ -
BoundParam bp = new BoundParam(index, obj, targetSqlType); -
boundParams.remove(bp); -
boundParams.add(bp ); -
} -
-
public void setObject(int index, Object obj, int targetSqlType, int scale) throws SQLException{ -
BoundParam bp = new BoundParam(index, obj, targetSqlType, scale) ; -
boundParams.remove(bp); -
boundParams.add(bp); -
} -
-
public void setString(int index, String str)throws SQLException{ -
BoundParam bp = new BoundParam(index, str) ; -
boundParams.remove(bp); -
boundParams.add(bp); -
} -
-
public void setTimestamp(int index, Timestamp timestamp)throws SQLException{ -
BoundParam bp = new BoundParam(index, timestamp) ; -
boundParams.remove(bp); -
boundParams.add( bp ); -
} -
-
public void setInt(int index, int value)throws SQLException{ -
BoundParam bp = new BoundParam(index, new Integer(value)) ; -
boundParams.remove(bp); -
boundParams.add( bp ); -
} -
-
public void setLong(int index, long value)throws SQLException{ -
BoundParam bp = new BoundParam(index, new Long(value)) ; -
boundParams.remove(bp); -
boundParams.add( bp ); -
} -
-
public void setDouble(int index, double value)throws SQLException{ -
BoundParam bp = new BoundParam(index, new Double(value)) ; -
boundParams.remove(bp); -
boundParams.add( bp); -
} -
-
public void setBigDecimal(int index, BigDecimal bd)throws SQLException{ -
BoundParam bp = new BoundParam(index, bd ) ; -
boundParams.remove(bp); -
boundParams.add( bp); -
} -
private void setParams(PreparedStatement pst) throws SQLException{ -
if (pst==null || this.boundParams==null || this.boundParams.size()==0 ) return ; -
BoundParam param; -
for (Iterator itr = this.boundParams.iterator();itr.hasNext();){ -
param = (BoundParam) itr.next(); -
if (param==null) continue; -
if (param.sqlType == java.sql.Types.OTHER){ -
pst.setObject(param.index, param.value); -
}else{ -
pst.setObject(param.index, param.value, param.sqlType, param.scale); -
} -
} -
}
分页技术(3)
最新推荐文章于 2023-08-15 16:05:29 发布