📄 searchdao.java
字号:
package com.chinaaccpDao;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import com.chinaaccpbean.Display;
public class SearchDao {
public ArrayList GetSortSearchInfo(String search)
{
String id = null;
System.out.println(search);
ArrayList list = new ArrayList();
Connection con = null;
try {
con = ConnectionLee.GetCon();
Statement st = con.createStatement();
String sql = "select id from Category where name='"+search+"'";
ResultSet rs = st.executeQuery(sql);
if(rs.next())
{
id = rs.getString(1);
}
//st.close();
//con.close();
} catch (Exception e) {
e.printStackTrace();
}
try {
Statement st = con.createStatement();
String sql = "select id,name,descinfo,price,picture,picture_big from product where categoryid="+id+"";
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
Display dis = new Display();
dis.setId(rs.getInt(1));
dis.setName(rs.getString(2));
dis.setDiscinfo(rs.getString(3));
dis.setPrice(rs.getDouble(4));
dis.setImgpath(rs.getString(5));
dis.setBigimgpath(rs.getString(6));
list.add(dis);
}
st.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
public ArrayList GetNameInfo(String name)
{
ArrayList list = new ArrayList();
System.out.println(name);
Connection con = null;
try {
con = ConnectionLee.GetCon();
Statement st = con.createStatement();
String sql = "select id,name,descinfo,price,picture,picture_big from product where name like '%"+name+"%'";
ResultSet rs = st.executeQuery(sql);
while(rs.next())
{
Display dis = new Display();
dis.setId(rs.getInt(1));
dis.setName(rs.getString(2));
dis.setDiscinfo(rs.getString(3));
dis.setPrice(rs.getDouble(4));
dis.setImgpath(rs.getString(5));
dis.setBigimgpath(rs.getString(6));
list.add(dis);
}
st.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -