📄 hold.java
字号:
package library;
import java.sql.*;
/**
* A class representing a hold.
*
* @author dms
* @version 1.0
*
*/
public class Hold extends LibraryObject {
private String callNumber;
private Member holder;
private java.sql.Timestamp holdDateTime;
/**
* public class Hold constructor
*
*/
public Hold(){}
/**
* class Hold constructor that runs query
* to load a set of holds. Use inherited
* method <code>getNext()</code> to iterate
* through the returned Hold objects. This
* constructor has default access, so only
* classes in this package can use this
* constructor. This effectively restricts the
* use of this constructor to the Model.
* @param sSQL String containing SQL statement
* @throws SQLException
*/
Hold(String sSQL) throws SQLException {
ensureconnection();
mr = db.runQuery(sSQL);
}
protected void setVariables(ResultSet r) throws SQLException {
callNumber = r.getString("callnumber");
holdDateTime = r.getTimestamp("holdDateTime");
holder = new Member();
holder.setConnection(db);
holder.getMember(r.getInt("ssn"));
}
/**
* This method releases the current hold.
*
* @throws SQLException
*/
public void releaseHold() throws SQLException {
String sSQL = "DELETE FROM Hold WHERE ssn = " + this.getHolder().getSSN() +
" AND CallNumber = '" + this.getCallNumber() + "'";
db.executeQuery(sSQL);
}
/**
* Accessor for Call Number
* @return String
*/
public String getCallNumber() {return callNumber;}
/**
* Accessor for hold date time
* @return String
*/
public Timestamp getHoldDateTime() {return holdDateTime;}
/**
* Accessor for holder member
* @return Member
*/
public Member getHolder() {
return holder;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -