book.java

来自「图书管理系统,可以查询 图书管理系统,可以查询」· Java 代码 · 共 73 行

JAVA
73
字号
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.net.*;
import java.lang.*;
import java.util.*;


public class Book{
    String ID;
    String name;
    String author;
    String publish;
    boolean isLoanable=true;
    Connection con = DBAccess.getConnection();
    
    public String getID(){
        return ID;
    }
    public String getname(){
        return name;
    }
    public String getauthor(){
        return author;
    }
    public String getpublish(){
        return publish;
    }
    public boolean getisLoanable(){
        return isLoanable;
    }
    
    
    public void setID(String ID){
        this.ID = ID;
    }
    public void setname(String name){
        this.name = name;
    }    
    public void setauthor(String author){
        this.author = author;
    }
    public void setpublish(String publish){
        this.publish = publish;
    }
    public void setisLoanable(boolean isLoanable){
        this.isLoanable = isLoanable;
    }    
    
    //search books from database
    public Vector serachBookByKey(String id){    	
    	Vector lst=new Vector();
    	try{
    		String s = "%" + id + "%";
        	String sql = "select id,name from book where ID like ?";
        	
        	PreparedStatement pst = con.prepareStatement(sql);
            pst.setString(1, s);
        	ResultSet rst=pst.executeQuery();
    	    
    	    while(rst.next()){
    	    	Vector v = new Vector();
    	    	v.add(rst.getString("ID"));
    	    	v.add(rst.getString("name"));
    	    	lst.add(v);	    		
    	    }  	    
        }catch(SQLException e){
        	System.out.print("SQLException"+e.getMessage());
        }  
         return lst;        
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?