📄 book.java
字号:
package ksnb;
import java.sql.*;
public class Book {
Statement st;
private ResultSet rs=null;
private String strsql=null;
private Connection c=null;
private conn con = null;
//Q_Book()方法用来返回和id值相同的书籍的所有内容
public Book(){
try{
con = new conn();
st = con.con.createStatement();
}catch(Exception e){
System.out.println(e.toString());
}
}
//分类查询
public ResultSet Q_Book(int id) {
try {
rs = st.executeQuery("select * from Shop_Product_Info where Catalog_Id=" + id);
} catch (Exception e) {
System.out.println(e.toString());
}
return rs;
}
//得到新书的方法
public ResultSet Q_newbook(){
try{
System.out.println("Q_newbook方法");
strsql="select * from Shop_Product_Info where New_book=1";
c = (new conn()).getConncetion();
//创建一个可以滚动的只读的SQL语句对象
st = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//执行SQL语句并获取结果集
rs = st.executeQuery(strsql);
System.out.println("Q_newbook方法ok");
}catch(Exception e){
System.out.println(e.toString());
}
return rs;
}
//获得热门书的方法,按点击次数排列
public ResultSet Q_rootbook(){
try{
strsql = "select * from Shop_product_info order by Click Desc";
c = (new conn()).getConncetion();
//创建一个可以滚动的只读的SQL语句对象
st = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//执行SQL语句并获取结果集
rs = st.executeQuery(strsql);
}catch(Exception e){
System.out.println(e.toString());
}
return rs;
}
//全部特价书
public ResultSet Q_tejiabook_info(){
try{
rs=st.executeQuery("select * from Shop_product_info where discount<=5 order by discount");
}catch(Exception e){
System.out.println(e.toString());
}
return rs;
}
public void getClose() {
try {
con.conClose();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -