forked from elenaxenouu/BookIt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerDAO.java
More file actions
28 lines (25 loc) · 1015 Bytes
/
Copy pathCustomerDAO.java
File metadata and controls
28 lines (25 loc) · 1015 Bytes
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
import java.sql.*;
public class CustomersDAO {
public void insertCustomer(User user) throws DuplicateFieldException, Exception {
DB db = new DB();
Connection con = null;
String sql = "INSERT INTO customers (fullname,service_number,Availability) VALUES (?,?,?);";
try {
con = db.getConnection();
PreparedStatement smt = con.prepareStatement(sql);
smt.setString(1, user.getName());
smt.setString(2, user.getAvailableHours());
smt.setService(3, user.getSelectedService());
smt.executeUpdate();
smt.close();
db.close();
} catch (Exception e) {
throw new Exception(e.getMessage());
} finally {
try {
db.close();
} catch (Exception e) {
}
}
}
}