📄 pageableresultset2.java
字号:
package com.msis.seacher;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.NClob;
import java.sql.Ref;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Map;
public class PageableResultSet2 implements Pageable {
protected java.sql.ResultSet rs=null;
protected int rowsCount;
protected int pageSize;
protected int curPage;
protected String command = "";
public PageableResultSet2(java.sql.ResultSet rs) throws java.sql.SQLException {
if(rs==null) throw new SQLException("given ResultSet is NULL","user");
rs.last();
rowsCount=rs.getRow();
rs.beforeFirst();
this.rs=rs;
}
public int getCurPage() {
return curPage;
}
/**返回总页数
*/
public int getPageCount() {
if(rowsCount==0) return 0;
if(pageSize==0) return 1;
//calculate PageCount
double tmpD=(double)rowsCount/pageSize;
int tmpI=(int)tmpD;
if(tmpD>tmpI) tmpI++;
return tmpI;
}
/**返回当前页的记录条数
*/
public int getPageRowsCount() {
if(pageSize==0) return rowsCount;
if(getRowsCount()==0) return 0;
if(curPage!=getPageCount()) return pageSize;
return rowsCount-(getPageCount()-1)*pageSize;
}
/**返回分页大小
*/
public int getPageSize() {
return pageSize;
}
/**返回总记录行数
*/
public int getRowsCount() {
return rowsCount;
}
/**转到指定页
*/
public void gotoPage(int page) {
if (rs == null)
return;
if (page < 1)
page = 1;
if (page > getPageCount())
page = getPageCount();
int row = (page - 1) * pageSize + 1;
try {
rs.absolute(row);
curPage = page;
}
catch (java.sql.SQLException e) {
}
}
/**
* 转到当前页的第一条记录
* @exception java.sql.SQLException 异常说明。
*/
public void pageFirst() throws java.sql.SQLException {
int row=(curPage-1)*pageSize+1;
rs.absolute(row);
}
public void pageLast() throws java.sql.SQLException {
int row=(curPage-1)*pageSize+getPageRowsCount();
rs.absolute(row);
}
public void setPageSize(int pageSize) {
if(pageSize>=0){
this.pageSize=pageSize;
curPage=1;
}
}
@Override
public boolean absolute(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public void afterLast() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void beforeFirst() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void cancelRowUpdates() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void clearWarnings() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void close() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public void deleteRow() throws SQLException {
// TODO Auto-generated method stub
}
@Override
public int findColumn(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean first() throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public Array getArray(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Array getArray(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getAsciiStream(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getAsciiStream(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BigDecimal getBigDecimal(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BigDecimal getBigDecimal(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public BigDecimal getBigDecimal(String arg0, int arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getBinaryStream(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getBinaryStream(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Blob getBlob(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Blob getBlob(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean getBoolean(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getBoolean(String arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public byte getByte(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public byte getByte(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public byte[] getBytes(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public byte[] getBytes(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Reader getCharacterStream(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Reader getCharacterStream(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Clob getClob(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Clob getClob(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getConcurrency() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getCursorName() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Date getDate(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Date getDate(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Date getDate(int arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Date getDate(String arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public double getDouble(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public double getDouble(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getFetchDirection() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getFetchSize() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public float getFloat(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public float getFloat(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getHoldability() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getInt(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getInt(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getLong(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public long getLong(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public ResultSetMetaData getMetaData() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Reader getNCharacterStream(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Reader getNCharacterStream(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NClob getNClob(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public NClob getNClob(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getNString(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getNString(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getObject(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getObject(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getObject(int arg0, Map<String, Class<?>> arg1)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getObject(String arg0, Map<String, Class<?>> arg1)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Ref getRef(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Ref getRef(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getRow() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public RowId getRowId(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public RowId getRowId(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public SQLXML getSQLXML(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public SQLXML getSQLXML(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public short getShort(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public short getShort(String arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public Statement getStatement() throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getString(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Time getTime(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Time getTime(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Time getTime(int arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Time getTime(String arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Timestamp getTimestamp(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Timestamp getTimestamp(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Timestamp getTimestamp(int arg0, Calendar arg1) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public Timestamp getTimestamp(String arg0, Calendar arg1)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getType() throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public URL getURL(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public URL getURL(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getUnicodeStream(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public InputStream getUnicodeStream(String arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public SQLWarning getWarnings() throws SQLException {
// TODO Auto-generated method stub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -