?? twotitle.java
字號:
package com.mybean;
import java.sql.*;
import java.util.ArrayList;
import com.myopdb.*;
public class TwoTitle {
private int twoid;
private int oneid;
private String twotitle;
private String onetitle;
private String titlepath;
private Connection con = null;
private Statement stmt = null;
private ResultSet rs = null;
DBCon dbo = new DBCon();
public String getTitlepath() {
return titlepath;
}
public void setTitlepath(String titlepath) {
this.titlepath = titlepath;
}
public String getTwotitle() {
return twotitle;
}
public void setTwotitle(String twotitle) {
this.twotitle = twotitle;
}
public boolean addTwoTitle(TwoTitle two) {
return true;
}
public int getTwoid() {
return twoid;
}
public void setTwoid(int twoid) {
this.twoid = twoid;
}
public String getOnetitle() {
return onetitle;
}
public void setOnetitle(String onetitle) {
this.onetitle = onetitle;
}
public int getOneid() {
return oneid;
}
public void setOneid(int oneid) {
this.oneid = oneid;
}
public ArrayList getAllTwoTitle(String title) {
String temp = title.substring(1, title.length() - 1);
ArrayList<Object> lst = new ArrayList<Object>();
this.con = dbo.getCon();
TwoTitle two;
final String sql = "select twotitle,titlepath from twoTitle where oneid in(select oneid from onetitle where onetitle='"
+ temp + "')";
try {
stmt = con.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
two = new TwoTitle();
two.setTwotitle(rs.getString(1));
two.setTitlepath(rs.getString(2));
lst.add(two);
}
} catch (SQLException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
return null;
}
return lst;
}
int intRowCount;// 數(shù)據(jù)的總記錄數(shù)
int intPageCount;// 總頁數(shù)
int intPageSize = 10;// 每頁行數(shù)
int intPage;// 當(dāng)前第幾頁
public ArrayList getAllTwoTitle(int curpage) {
TwoTitle two;
ArrayList<Object> lst = new ArrayList<Object>();
final String sql = "select * from One_Two_view order by twoid";
this.con = dbo.getCon();
if (con != null) {
try {
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
System.out.println(intRowCount);
if (intRowCount % intPageSize == 0) {
intPageCount = intRowCount / intPageSize;
} else {
intPageCount = intRowCount / intPageSize + 1;
}
if (curpage == 0) {
intPage = 1;
} else {
intPage = curpage;
if (intPage < 1 || intPage > intPageCount) {
intPage = 1;
}
}
// 將對記錄集進行操作,以顯示數(shù)據(jù),
// 首先要將記錄集的指針移到要顯示頁面的第一條記錄上面
rs.absolute((intPage - 1) * intPageSize + 1);
// 循環(huán)顯示當(dāng)前指定頁面的數(shù)據(jù)
int i = 0;
while (i < intPageSize && !rs.isAfterLast()) {
two = new TwoTitle();
two.setTwoid(rs.getInt(1));
two.setOnetitle(rs.getString(2));
two.setTwotitle(rs.getString(3));
two.setTitlepath(rs.getString(4));
lst.add(two);
rs.next();
i++;
}
System.out.println(i);
} catch (SQLException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
return null;
}
}
lst.add(this.intPage);
lst.add(this.intPageCount);
return lst;
}
public boolean inserTwoTitle(TwoTitle tt)
{
String sql="insert into twotitle values("+tt.getOneid()+",'"+tt.getTwotitle()+"','"+tt.getTitlepath()+"')";
if(this.con==null)
{
this.con=dbo.getCon();
}
try {
stmt=con.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
return false;
}
return true;
}
public boolean deleteTwoTitle(TwoTitle tt)
{
String sql="delete from twotitle where twoid="+tt.getTwoid()+"";
if(this.con==null)
{
this.con=dbo.getCon();
}
try {
stmt=con.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
return false;
}
return true;
}
public boolean updateTwoTitle(TwoTitle tt)
{
String sql="update twotitle set twotitle='"+tt.getTwotitle()+"',titlepath='"+tt.getTitlepath()+"' where twoid="+tt.getTwoid()+"";
if(this.con==null)
{
this.con=dbo.getCon();
}
try {
stmt=con.createStatement();
stmt.executeUpdate(sql);
} catch (SQLException e) {
// TODO 自動生成 catch 塊
e.printStackTrace();
return false;
}
return true;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -