-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReissuerBook.java
More file actions
36 lines (33 loc) · 1.06 KB
/
ReissuerBook.java
File metadata and controls
36 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.time.LocalDate;
public class ReissuerBook implements Runnable{
static String name;
public static int ret;
public ReissuerBook(String tname){
name = tname;
Thread t = new Thread(this);
t.start();
}
@Override
public void run() {
reissueBook();
}
synchronized static void reissueBook(){
try{
Database_DAO.connect();
java.sql.Date sqlDate = Database_DAO.getBookDueDate(name);
LocalDate ld = sqlDate.toLocalDate();
LocalDate cd = LocalDate.now();
if(cd.isBefore(ld)) {
String query = "UPDATE book SET issueno=2,duedate=adddate(current_date(),15) WHERE bname=? AND issueno=1";
Database_DAO.pst = Database_DAO.con.prepareStatement(query);
Database_DAO.pst.setString(1, name);
ret = Database_DAO.pst.executeUpdate();
}
else ret = 0;
}
catch(Exception e){
System.out.println(e.getMessage());
ret = 0;
}
}
}