📄 listposition.java
字号:
package com.everstar.career;
/**
* Title: webstar
* Description: this is the webstar project
* $ Modified Record:
$2003.4.6: Created.
* Copyright (C) 2003 www.studyjava.com All rights reserved.
* @version 1.0
*/
import java.util.*;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.everstar.database.*;
public class ListPosition {
private int recFrom = 1; // first record displayed
private int numRecPerPage = 20; // maximum number of records displayed
private String actPrev = null; //previous page
private String actNext = null; //next page
private Database dbConn = null; //database connection
private String error = null;
private Vector bcBeans = new Vector();
public int getRecFrom() { return(recFrom); }
public void setRecFrom(int newRecFrom) { recFrom = newRecFrom; }
public int getNumRecPerPage() { return(numRecPerPage); }
public void setNumRecPerPage(int newNumRecPerPage) { numRecPerPage = newNumRecPerPage; }
public String getActPrev() { return(actPrev); }
public void setActPrev(String newActPrev) { actPrev = newActPrev; }
public String getActNext() { return(actNext); }
public void setActNext(String newActNext) { actNext = newActNext; }
public Database getDbConn() { return(dbConn); }
public void setDbConn(Database newDbConn) { dbConn = newDbConn; }
public void setError(String newError) { error = newError;}
public String getError() { return error;}
public void init() throws ServletException {
if (dbConn == null) error = "No Database Connection!";
int start = recFrom;
int count = numRecPerPage;
if (actNext != null) start += numRecPerPage;
else if (actPrev != null) {
if ((start -= numRecPerPage) < 1) start = 1;
} else start = 1;
recFrom = start;
try {
String sqlstr = "select * from position";
ResultSet rs = dbConn.select(sqlstr);
while (--start > 0 && rs.next()); // jump to the first one
bcBeans.clear() ;
int i = 0 ;
while( count-- > 0 && rs.next() ){
i=1;
PositionInformation bcBean= new PositionInformation();
bcBean.setPositionId(rs.getInt(i++));
bcBean.setPositionName(rs.getString(i++));
bcBean.setPositionDetail(rs.getString(i++));
bcBean.setPositionRequest(rs.getString(i++)) ;
bcBean.setCount(rs.getInt(i++));
bcBeans.add(bcBean);
}
rs.close();
dbConn.close();
}catch (Exception e){
error = "SQL Error";
}
}
public int getNumRec(){return(getNumOfPosition());}
public int getNumOfPosition(){ return(bcBeans.size()); }
public PositionInformation getPosition(int idx) {
return((PositionInformation)bcBeans.elementAt(idx));
}
public ListPosition() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -