My database connection (3)

xiaoxiao2021-03-06  82

I am using the paging display in JSP.

// Source File: C: //pageresultset.java

Package DB;

Import java.sql. *;

Public class pageresultset {

Private resultset RST;

Private ResultSetMetadata RSMD;

Private int point;

PRIVATE INT pageCOUNT;

Private int rows;

Private int Pagerows = 10;

Private viewquerybean v;

Public PageResultset ()

{

Try {

v = new viewQuerybean ();

}

Catch (Sqlexception EX) {EX.PrintStackTrace ();

}

}

Public void deleterow () throws sqlexception {

Rst.deleterow ();

Public void init () //

{

INITPAGE (); // Ready Rowcount, PageCount, CurrentPage

INITRSMD (); // ready resultsetmetata;

}

Public int getColumncount () {

Try {

Return RSMD.GetColumnCount ();

}

Catch (Sqlexception EX) {

Return 0;

}

}

Public String getColumnLabel (int index)

{

Try {

Return RSMD.GetColumnLabel (INDEX);

}

Catch (Sqlexception EX) {

""; "

}

}

Private vid initpage () {

IF (ROWS% PAGEROWS == 0)

{PageCount = rows / PageRows;

Else

{PageCount = ROWS / PAGEROWS 1;

}

System.out.println ("Page" PageCount;

}

Private vid initrsmd () {

Try {RSMD = Rst.getMetadata ();

}

Catch (Sqlexception S)

{}

}

Public void ExecuteQuery (String SQL) THROWS SQLEXCEPTION {

THIS.SETRST (V.ExecuteQuery (SQL));

this.Rows = v.Getrowcount (); //

THIS.INIT ();

Public void scrolltopage (int page) {

INT I;

I = (page -1) * this.pageROWS 1;

Try {Rst.absolute (i);

System.out.println ("Absolute =" i);

}

Catch (Sqlexception S)

{System.out.println (s);}

}

Public Void ScrollTorows (INT i)

{

Try {Rst.absolute (i);

System.out.println ("Absolute Success");

}

Catch (Sqlexception S)

{S.PrintStackTrace ();

}

Public ResultSet GetRST ()

{

Return RST;

}

Public void setrst (ResultSet ARST)

{

RST = ARST;

}

Public int getpage ()

{

Return Page;

}

Public void setpage (int page) {

THIS.PAGE = Page;}

Public int getRows ()

{

Return rows;

}

Public void setRows (int Row)

{

THIS.ROWS = row;}

Public int getpagerows ()

{

Return PageROWS;

}

Public void setpagerows (int apagerows)

{

PageROWS = apagerows;

}

Public boolean next () {

Try {

Return Rst.next ();

}

Catch (Sqlexception EX) {

Return False;

}

}

Public string getstring (int index) {{INT INDEX

Try {

Return Rst.getstring (INDEX);

}

Catch (Sqlexception EX) {

Return NULL;

}

}

Public string getString (String ColumnName) {

Try {

Return Rst.getstring (ColumnName);

}

Catch (Sqlexception EX) {

Return NULL;

}

Public int getPagecount () {

Return this.pagecount;

Public void close () {

IF (this.rst! = null) this.rst = NULL;

IF (this.v! = null) .v.close ();

}

}

转载请注明原文地址:https://www.9cbs.com/read-107022.html

New Post(0)