📄 selectlist.java
字号:
package db;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class selectList {
// 获得总的记录数目
public static int getRowNumber() {
Connection conn = OracleConn.getConnection();
int num = 0;
try {
Statement stmt = conn.createStatement();
String sql = "select count(*) as rowNumbers from AddressList";
ResultSet rs = stmt.executeQuery(sql);
rs.next();
num = rs.getInt("rowNumbers");
} catch (SQLException e) {
e.printStackTrace();
} finally {
OracleConn.closeConnection(conn);
}
return num;
}
// 根据指定的页面大小,获得页面数目。
public static int getTotalPage(int pageSize) {
int totalPage = 1;
int tmpPage = 0;
int rowNum = getRowNumber();
tmpPage = rowNum % pageSize;
if (tmpPage == 0) {
totalPage = rowNum / pageSize;
} else {
totalPage = (int) (Math.floor(rowNum / pageSize) + 1);
}
if (totalPage == 0) {
totalPage = 1;
}
return totalPage;
}
public static ResultSet getAllResult() {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = "select * from AddressList order by id";
try {
conn = OracleConn.getConnection();
//获得可滚动的ResultSet,但不可更新
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -