package dbBean;
import java.sql.ResultSet;
import dbBean.dbConnection;
public class searchBean
{
public void initSearch(int Book_type_ID,String Book_name,String author,String Translator,String Publish_house,String ISBN,String Congshu_name)//,int storage)
{
this.Book_type_ID=Book_type_ID;
this.Book_name=Book_name;
this.author=author;
this.Translator=Translator;
this.Publish_house=Publish_house;
this.ISBN=ISBN;
this.Congshu_name=Congshu_name;
this.storage=storage;
}
public ResultSet SearchBook()
{
//任何人都可以查询,则USER设置为everyUser
dbConnection dbConn=new dbConnection();
dbConn.getConnect("bookshop", "user", "123");
String sql="select * from Book where Book_type_ID="+Book_type_ID;
//+" and Book_name='"+Book_name+"'"+" and author='"+author+"'"+" and Translator='"+Translator+"'"+" and Publish_house='"+Publish_house+"'"+" and ISBN='"+ISBN+"'"+" and Storage_num>0";
// String sql="select * from Book where Book_name like '"+Book_name+"'";
if(Book_name!="")
{
sql=sql+" and Book_name='"+Book_name+"'" ;
}
if(author!="")
{
sql=sql+" and author='"+author+"'";
}
if(Translator!="")
{
sql=sql+" and Translator='"+Translator+"'";
}
if(Publish_house!="")
{
sql=sql+" and Publish_house='"+Publish_house+"'";
}
if(ISBN!="")
{
sql=sql+" and ISBN='"+ISBN+"'";
}
/** if(storage==1)
{
sql=sql+" and Storage_num>0";
}
**/
System.out.println(sql);
ResultSet rs=dbConn.selectSql(sql);
return rs;
}
private int Book_type_ID;
private String Book_name;
private String author;
private String Translator;
private String Publish_house;
private String ISBN;
private String Congshu_name;
private int storage;
//private dbConnection dbConn;
}
评论0