⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pageableresultset2.java

📁 特色说明: 1.沿袭今晚在线论坛独有的双风格分桢形式 2.社区最多可进行3级分类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.gamvan.sql;import java.sql.*;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 PageableResultSet2(java.sql.ResultSet rs, String command) 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;            this.command = command;    }    public int getCurPage() {        return curPage;    }    //////////////////////////    public java.net.URL getURL(String columnName) throws SQLException{        return rs.getURL(columnName);    }    public java.net.URL getURL(int columnName) throws SQLException{        return rs.getURL(columnName);    }    /////////////////////////////////    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) {        }    }    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;        }    }  //============================================================================    public boolean absolute(int row) throws SQLException {            return rs.absolute(row);    }    public void afterLast() throws SQLException {            rs.afterLast();    }    public void beforeFirst() throws SQLException {            rs.beforeFirst();    }    public void cancelRowUpdates() throws SQLException {            rs.cancelRowUpdates();    }    public void clearWarnings() throws SQLException {            rs.clearWarnings();    }    public void close() throws SQLException {            rs.close();    }    public void deleteRow() throws SQLException {            rs.deleteRow();    }    public int findColumn(String columnName) throws SQLException {	try            {                    return rs.findColumn(columnName);            }            catch (SQLException e)            {                    throw new SQLException(e.toString()+ "/"+columnName + "/"+this.getCommand());            }    }    public boolean first() throws SQLException {            return rs.first();    }    public Array getArray(int i) throws SQLException {            try            {                    return rs.getArray(i);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+i                            +"\r\nSQL="+this.getCommand());            }    }    public Array getArray(String colName) throws SQLException {	try	{		return rs.getArray(colName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+colName			+"\r\nSQL="+this.getCommand());	}}    public java.io.InputStream getAsciiStream(int columnIndex) throws SQLException {	try	{		return rs.getAsciiStream(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public java.io.InputStream getAsciiStream(String columnName) throws SQLException{	try	{		return rs.getAsciiStream(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}}    public java.math.BigDecimal getBigDecimal(int columnIndex) throws SQLException {	try	{		return rs.getBigDecimal(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}		}    public java.math.BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {	throw new SQLException("Deprecated Method, Don't Call it!","user");}    public java.math.BigDecimal getBigDecimal(String columnName) throws SQLException {	try	{		return rs.getBigDecimal(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}}    public java.math.BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {            throw new SQLException("Deprecated Method, Don't Call it!","user");    }    public java.io.InputStream getBinaryStream(int columnIndex) throws SQLException{	try	{			return rs.getBinaryStream(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public java.io.InputStream getBinaryStream(String columnName) throws SQLException {	try	{		return rs.getBinaryStream(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}	}    public Blob getBlob(int columnIndex) throws SQLException {	try	{		return rs.getBlob(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public Blob getBlob(String colName) throws SQLException{	try	{		return rs.getBlob(colName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+colName			+"\r\nSQL="+this.getCommand());	}}    public boolean getBoolean(int columnIndex) throws SQLException {            try            {                    return rs.getBoolean(columnIndex);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+columnIndex                            +"\r\nSQL="+this.getCommand());            }    }    public boolean getBoolean(String columnName) throws SQLException {	try	{		return rs.getBoolean(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}}    public byte getByte(int columnIndex) throws SQLException {	try	{		return rs.getByte(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public byte getByte(String columnName) throws SQLException{	try	{			return rs.getByte(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}}    public byte[] getBytes(int columnIndex) throws SQLException {	try	{		return rs.getBytes(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public byte[] getBytes(String columnName) throws SQLException{	try	{		return rs.getBytes(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}	}    public java.io.Reader getCharacterStream(int columnIndex) throws SQLException {	try	{		return rs.getCharacterStream(columnIndex);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" column Index="+columnIndex			+"\r\nSQL="+this.getCommand());	}}    public java.io.Reader getCharacterStream(String columnName) throws SQLException {            try            {                    return rs.getCharacterStream(columnName);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" columnName="+columnName                            +"\r\nSQL="+this.getCommand());            }    }    public Clob getClob(int i) throws SQLException {            try            {                    return rs.getClob(i);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+i                            +"\r\nSQL="+this.getCommand());            }    }    public Clob getClob(String colName) throws SQLException{            try            {                    return rs.getClob(colName);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" columnName="+colName                            +"\r\nSQL="+this.getCommand());            }    }    public java.lang.String getCommand() {            return command;    }    public int getConcurrency() throws SQLException {            return rs.getConcurrency();    }    public String getCursorName() throws SQLException {            return rs.getCursorName();    }    public Date getDate(int columnIndex) throws SQLException{            try            {                    return rs.getDate(columnIndex);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+columnIndex                            +"\r\nSQL="+this.getCommand());            }    }    public Date getDate(int columnIndex, java.util.Calendar cal) throws SQLException{            try            {                    return rs.getDate(columnIndex,cal);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+columnIndex                            +"\r\nSQL="+this.getCommand());            }    }    public Date getDate(String columnName) throws SQLException{            try            {                    return rs.getDate(columnName);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" columnName="+columnName                            +"\r\nSQL="+this.getCommand());            }    }    public Date getDate(String columnName, java.util.Calendar cal) throws SQLException {            try            {                    return rs.getDate(columnName,cal);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" columnName="+columnName                            +"\r\nSQL="+this.getCommand());            }    }    public double getDouble(int columnIndex) throws SQLException {            try            {                    return rs.getDouble(columnIndex);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+columnIndex                            +"\r\nSQL="+this.getCommand());            }    }    public double getDouble(String columnName) throws SQLException {            try            {                    return rs.getDouble(columnName);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" columnName="+columnName                            +"\r\nSQL="+this.getCommand());            }    }    public int getFetchDirection() throws SQLException {            return rs.getFetchDirection();    }    public int getFetchSize() throws SQLException {            return rs.getFetchSize();    }    public float getFloat(int columnIndex) throws SQLException{            try            {                    return rs.getFloat(columnIndex);            }            catch (SQLException e)            {                    throw new SQLException (e.getMessage()+" column Index="+columnIndex                            +"\r\nSQL="+this.getCommand());            }    }	    public float getFloat(String columnName) throws SQLException {	try	{		return rs.getFloat(columnName);	}	catch (SQLException e)	{		throw new SQLException (e.getMessage()+" columnName="+columnName			+"\r\nSQL="+this.getCommand());	}}    public int getInt(int columnIndex) throws SQLException {            try            {                    return rs.getInt(columnIndex);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -